So in C#, there is something called “the switch block”
pretty much a better if elseif elseif elseif elseif else statement.
it goes like this:
string MyString = "Hello"
Console.WriteLine("No matches have been found :(");
i would like to know this, since i don’t want to be typing if, elseif , elseif ,elseif, every time…
the switch block is primarily made to take an object and compare it against other objects, as you can see in the example i provided. if no matches are found it runs default, unless there’s none.
so i wonder if lua has this?
because right now this is what the lua equivalent would look like without using the switch block:
local Mystring = "hello"
if Mystring == "apple" then
elseif Mystring == "String" then
elseif Mystring == "hello" then
print("No matches have been found :(")
for me this is way more to type, but it could just be my lazyness acting up again …
so do you know if a lua equivalent switch block exists?
local function switch(val)
if tbl[val] == nil then
local MyString = "abc"
Hello = function()
Apple = function()
String = function()
default = function()