switch value
when "cool"
print "hello world"
switch value
when "cool"
print "hello world"
else
print "okay rad"
switch value
when "cool"
print "hello world"
when "yeah"
_ = [[FFFF]] + [[MMMM]]
when 2323 + 32434
print "okay"
else
print "okay rad"
out = switch value
when "cool" then print "hello world"
else print "okay rad"
out = switch value
when "cool" then xxxx
when "umm" then 34340
else error "this failed big time"
with something
switch \value!
when .okay
_ = "world"
else
_ = "yesh"
fix this
call_func switch something
when 1 then "yes"
else "no"
--
switch hi
when hello or world
_ = greene
--
switch hi
when "one", "two"
print "cool"
when "dad"
_ = no
switch hi
when 3+1, hello!, (-> 4)!
_ = yello
else
print "cool"
do
dict = {
{}
{1, 2, 3}
a: b: c: 1
x: y: z: 1
}
switch dict
when {
first
{one, two, three}
a: b: :c
x: y: :z
}
print first, one, two, three, c, z
do
items =
* x: 100
y: 200
* width: 300
height: 400
* false
for item in *items
switch item
when :x, :y
print "Vec2 #{x}, #{y}"
when :width, :height
print "Size #{width}, #{height}"
when false
print "None"
when __class: cls
switch cls
when ClassA
print "Object A"
when ClassB
print "Object B"
when #: mt
print "A table with metatable"
else
print "item not accepted!"
do
tb = {}
switch tb
when {:a = 1, :b = 2}
print a, b
switch tb
when {:a, :b = 2}
print "partially matched", a, b
switch tb
when {:a, :b}
print a, b
else
print "not matched"
do
tb = x: "abc"
switch tb
when :x, :y
print "x: #{x} with y: #{y}"
when :x
print "x: #{x} only"
do
matched = switch tb
when 1
"1"
when :x
x
when false
"false"
else
nil
do
return switch tb
when nil
"invalid"
when :a, :b
"#{a + b}"
when 1, 2, 3, 4, 5
"number 1 - 5"
when {:matchAnyTable = "fallback"}
matchAnyTable
else
"should not reach here unless it is not a table"
do
switch y
when {x: #: mt}
print mt
nil