[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Has Lua reached perfection?
- From: Sean Conner <sean@...>
- Date: Sun, 28 Jan 2018 03:26:19 -0500
It was thus said that the Great KHMan once stated:
> How many other major languages that avoids having a switch
> construct are there? Lua puts in a utf8 library but not a switch
Not built in, but ...
if case[var] then
x = 4
one = function() print "yada" end,
two = function() print "blah" end,
three = function() print "yahoo" end,
 = function() print "this is four" end,
You still have the overhead of a table lookup, but this is about as close
to a switch statement you can get in Lua without changing the language.