lua-users home
lua-l archive

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



On Mar 07, 2006, at 17:48, Gavin Kistner wrote:

I've added this information to
http://lua-users.org/wiki/MigratingToFiveOne
under "Using vararg expressions rather than 'arg'"

In addition, you might want to consider using table.maxn() when unpacking multiple return values:

function test()
    return "a", nil, "b", nil
end

local someResults = { test() }

print( "#", #someResults, unpack( someResults ) )
print( "maxn", table.maxn( someResults ), unpack( someResults, 1, table.maxn( someResults ) ) )

> #       1       a
> maxn    3       a       nil     b

Not perfect as one doesn't seem to be able to catch the very last nil value, but good enough for all practical purposes :)

Cheers

--
PA, Onnay Equitursay
http://alt.textdrive.com/