[24 Aug 2009] Documentation issue regarding NextItem()?

Contains all messages from the Hollywood mailing list between 01/2006 and 08/2012
Locked
nexus
Posts: 150
Joined: Sun Mar 07, 2010 11:54 am

[24 Aug 2009] Documentation issue regarding NextItem()?

Post by nexus »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Mon, 24 Aug 2009 10:26:22 +0200

The documentation says:

Code: Select all

"next , item = NextItem(table[,start])
...
 NextItem() then returns an index to the next
 value in the table and the first value in the table."
But actually NextItem() returns an index to the current value (item) that is returned (and not to the next value), Otherwise it would not be possible to copy a table, because you would never get the index to the very first element int the table.

"next" is then always a index to "item" in "table" for next, item = NextItem(table[,start]), right?

I'm just asking because I want to make sure that what I'm testing here does not just accidently work ;-)

Thanks, Tom
User avatar
airsoftsoftwair
Posts: 5834
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

[24 Aug 2009] Re: Documentation issue regarding NextItem()?

Post by airsoftsoftwair »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Mon, 24 Aug 2009 13:19:26 +0200
But actually NextItem() returns an index to the current value (item) that is returned (and not to the next value), Otherwise it would not be possible to copy a table, because you would never get the index to the very first element int the table.

"next" is then always a index to "item" in "table" for next, item = NextItem(table[,start]), right?
Yes, the documentation is a little bit wrong here. I'll have to fix this :) Actually, NextItem(), as the very name implies, always returns the *next* item i.e. the item *next* to "start". So if you pass in 0 for start, then NextItem() will return 1 and the value at index 1. If there's no value at index 1, it will return Nil. Because NextItem() always returns the next item we need one special case and that is when you want to retrieve the first item: In that case, you need to pass Nil as start. The next item to Nil will always be the first item! And when Nil is returned, there's no next item.

That's about it... I'll fix the documentation now :)
Locked