[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Newbie: select() function difference in 5.0 and 5.1
- From: "Ganesh Gunasegaran" <ganesh.gunasegaran@...>
- Date: Fri, 8 Dec 2006 22:47:09 +0530
I am currently reading "Programing Lua" first edition (I couldn't buy second edition from INDIA :( ).
In the first edition, it is mentioned that select() gives a specific return value of a function. So if the first argument of select() is 1, it returns the first return value.
print(string.find("hello hello", " hel")) > 6 9
print(select(1, string.find("hello hello", " hel"))) > 6
print(select(2, string.find("hello hello", " hel"))) > 9
But when I tried a sample, select was actually giving all the return values starting from the index specified.
function test(a, b)
return a, b
---------- Run ----------
Output completed (0 sec consumed) - Normal Termination
I cross checked in 5.1 reference.
select (index, ···)
If index is a number, returns all arguments after argument number index. Otherwise,
index must be the string "#", and select returns the total number of extra arguments it
Is this a new change in 5.1 ? If so, where can I get list of core language changes in 5.1 (since 5.0)? And may I ask the reason behind the change in select() function behavior in
I am from Java/J2EE => Ruby/Rails background. I initially thought Java was complex and moved to Ruby. Because of Lua, I feel Ruby is complex ;). I believe in doing more with less. Lua rocks.