lua-users home
lua-l archive

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


On Dec 16, 2009, at 8:36 PM, Cosmin Apreutesei wrote:

> I wish select('#',...) wouldn't count trailing nils for more symmetry:
> - f() same as f(nil)
> - return nothing same as return nil
> - unpack({...}) same as ...
> - f(unpack(t))

Take a look at unpack's full API:

http://www.lua.org/manual/5.1/manual.html#pdf-unpack

E.g.:

t = { n = select( '#', ... ), ... }

f( unpack( t, 1, t.n ) )

And full symmetry was achieved. 

This is even more important if some of your arguments could legitimately be nils, e.g.:

f( 'foo', nil, 'bar', nil )