lua-users home
lua-l archive

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


On Thu, Feb 12, 2004 at 09:45:55AM -0300, andrew cooke wrote:
> For example, if I want to add a "case" statement to Lua that looks
> something like:
> 
> case x
> of   1 do ... end
> of   2 do ... end
> else   do ... end
> 
> would I be able to?  My initial idea was to define case as a vararg
> function, but if arguments are evaluated eagerly then this won't work (I
> believe).

case(x){
   [1] = function() ... end
   [2] = function() ... end
}

Should be quite easy to implement.

-- 
Tuomo