[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re[2]: select("#", ...) idiom
- From: Doug Currie <doug.currie@...>
- Date: Wed, 14 Sep 2005 21:56:39 -0400
Wednesday, September 14, 2005, 4:09:39 PM, Roberto wrote:
> ... is an expression. #exp returns the length of the result of exp.
> So, #... is the length of the first argument of a vararg function.
> Try this:
> function f (...) return #... end
> print(f("hi", 4, 5))
... may be an expression, but the question is: what does # do when
applied to multiple values? It can discard all of them except the
first, or it can count them.
Given the second interpretation, #{whatever} and #"whatever" work as
now, but #... returns the count of arguments; you can still get the
behavior above with
> function g (...) return #(...) end
> print(g("hi", 4, 5))
2
> print(f("hi", 4, 5))
3
e