localswitch, case, default=require(LuaSwitch).getFunctions()
localmyUnknownPet=ifmath.random(1, 2) ==1then"dog" else"cat"switch (myUnknownPet) {
case"dog" (function(stop)
warn("My pet is a dog!")
--[[ the stop method skip the default function and stop to check the other cases, but doesn't stop the execution of the function]]stop() end)
case"cat" (function(stop)
warn("My pet is a cat!")
stop() end)
default(function()
print("I don't know what my pet is :(")
end)
}localswitch, case, default=require(LuaSwitch).getFunctions()
localvalue=0switch("B") {
case"A", -- Will execute case Ccase"B", -- Will execute case Ccase"C" (function()
value=2end),
default (function()
value-=1end)
}localvalue="B"ifvalue=="A" thenprint("Case A")
elseifvalue=="B" thenprint("Case B")
elseifvalue=="C" thenprint("Case C")
elseprint("Executing default")
endlocalswitch, case, default=require(LuaSwitch).getFunctions()
localvalue="B"switch(value) {
case"A" (function()
print("Case A")
end),
case"B" (function()
print("Case B")
end),
case"C" (function()
print("Case C")
end),
default(function()
print("Executing default")
end)
}localswitch, case, default=require(LuaSwitch).getFunctions()
localvalue="B"switch(value) {
case"A" (function()
print("Case A")
end),
case"B" (function()
print("Case B")
end),
case"C" (function()
print("Case C")
end),
default(function()
print("Executing default")
end)
}localswitch, case, default=require(LuaSwitch).getFunctions()
localvalue="B"switch(value) {
case"A" {
function()
print("Case A")
end
},
case"B" {
function()
print("Case B")
end
},
case"C" {
function()
print("Case C")
end
},
default { function()
print("Executing default")
end
}
}localswitch, case, default=require(LuaSwitch).getFunctions()
localclock=os.clocklocalc1=clock()
localvalue="C"localswitchTimeswitch(value) {
case"A",
case"B",
case"C" (function(stop)
print("Stacking cases!")
stop()
end)
}
switchTime=clock() -c1c1=clock()
ifvalue=="A" orvalue=="B" orvalue=="C" orvalue=="D" thenprint("Stacking cases!")
endprint("If Time:", clock() -c1)
print("Switch Time:", switchTime)