Examples · learn/06-enums · 123 of 339
values
match works on ints and strings too.
tin run examples/learn/06-enums/values.tin// match works on ints and strings too. _ matches anything else.
fn dayName(n: int): string => match n {
0 => "Sunday"
6 => "Saturday"
_ => "a weekday"
}
fn reply(word: string): string => match word {
"hi" => "hello!"
"bye" => "see you"
other => "I don't know '{other}'" // a name also matches anything, and keeps the value
}
fn main() {
print(dayName(6))
print(dayName(3))
print(reply("hi"))
print(reply("thanks"))
}