lua-users home
lua-l archive

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


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