lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




On 3/21/2012 12:19 PM, Egor Skriptunoff wrote:
local a,b,c=(''):byte(),1,2
print(a,b,c)
# nil 1 2

I would've thought this should be
# 1 2 nil

Lua reduces empty result list of
(''):byte()

to one value == nil.

But then type((''):byte()) bombs out that no parameter were given, and in the source code, string.byte it returns 0..n elements on the stack.



See chapter 'Expressions' in Lua Manual.

I'll take a look!




# Note the coma at the end
local a,b,c=('ab'):byte(1,2),
print(a,b,c)
# nil nil nil

It is equivalent to
local a,b,c=('ab'):byte(1,2),print(a,b,c)

It prints your global a,b,c  :)

LOL! Thanks for that one!