[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: '__iter', yet again!
- From: Petite Abeille <petite.abeille@...>
- Date: Wed, 16 Dec 2009 20:51:32 +0100
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 )
- References:
- Re: '__iter', yet again!, Jerome Vuarand
- Re: '__iter', yet again!, Jerome Vuarand
- Re: '__iter', yet again!, Luiz Henrique de Figueiredo
- Re: '__iter', yet again!, steve donovan
- Re: '__iter', yet again!, Javier Guerra
- Re: '__iter', yet again!, Mark Hamburg
- Re: '__iter', yet again!, Cosmin Apreutesei