lua-users home
lua-l archive

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


> 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.


See chapter 'Expressions' in Lua Manual. 



> # 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  :)

--Egor