ποΈPattern Matching
Syntax
match <expr> {
case <case expr>: {
<code block>
}
}<case expr> refers to any of the following:
An enum literal (e.g.
Circle()in the below example)Currently, you cannot pattern match on any field that is another enum literal. Support is currently being implemented for this.
A string (e.g.
"hello")An int (e.g.
30)A decimal (e.g.
5.0)A boolean (e.g.
true)A char (e.g.
'a')[Support Coming Soon]
Wildcard[Support Coming Soon]
Array literal (e.g.[2]string{"hello", "world"})[Support Coming Soon]
Slice literal (e.g.[]string{"hello", "world"})
Working Example
Last updated