[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Select (Switch) Case statement
- From: Eric Tetz <erictetz@...>
- Date: Wed, 1 Sep 2004 11:05:11 -0700
Asko Kauppi wrote:
> But it wouldn't hurt, either.
Well, it *would* make the language bigger -- without adding anything that can't
already be done just as easily and efficiently via if-elseif-else.
If they're going to be adding any major syntactical elements to Lua, I want
infix binary operators. ;)
Michael Roth wrote:
> local case, default = switch(i)
> if case(2) then
I don't understand how that is preferable to:
if i == 2 then
Mark Hamburg wrote:
> The problem with that version is that it builds the switch table every time.
YASS (Yet Another Switch Statement):
function switch(n, ...)
for i=1,arg.n do
if n == arg[i] then
case( DOG_BARK, function()
case( DOG_BITE, function()
case( DOG_SLEEP, function()