Switch statements are a nice way to go through a set of cases. We have ternary expressions that can be used in place of if
statements. It would be great to have an expression for switch
too.
For example, the match
expression in Rust, Scala, etc.
const k = 5;
const times = match (k) {
case 1 => "once"
case 3 => "thrice"
case 5 => "five times"
}