lua-users home
lua-l archive

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


On Mon, Mar 4, 2019 at 9:11 PM Magicks M <m4gicks@gmail.com> wrote:
function f() end
tostring(f()) --what happens here?
This code causes an error, which I think is not obvious, with the message "bad argument #1 to 'tostring' (value expected)" I believe this is because the number of values returned by f is 0 which means the vararg passed into tostring has length 0.


Even stranger: this works:

tostring( ( f() ) )

The extra parentheses adjust the number of return values of 'f' to be 1, introducing a nil value. 

-- 
--