lua-users home
lua-l archive

Re: Switch/Case statements revisited

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


On Nov 9, 2007 11:05 AM, Asko Kauppi <askok@dnainternet.net> wrote:
> How about making a "competition" or a quest for the perfect switch
> (if there is one) right here on the mailing list?
I'm wondering, was there ever a great language feature which came out
of a mailing list discussion? Not sarcastic, just genuinely
interested.
My vote is for David Given's suggestion:
match k
 with 10, 11 then return 1 end
 with 12 then return 2 end
 with i if 13<=i and i<=16 then return 4 end
end
It's understood to involve just linear chains of elseifs ;)
steve d.

AltStyle によって変換されたページ (->オリジナル) /