mers/examples/switch_match.mers

20 lines
388 B
Plaintext
Raw Normal View History

2023-05-26 20:02:46 +02:00
x := if true [10 "my text"] else 10
switch! x {
[int string] [num text] {
num.debug()
text.debug()
}
int num {
println("number:")
num.debug()
}
}
text := "12.5"
match {
parse_int(text) num println("int: " + num.to_string())
parse_float(text) num println("float: " + num.to_string())
true [] println("not a number: " + text)
}