tagcase <expr> <tag_arm> <tag_arm>* [others ":" <body>] endwhere
<tag_arm> -> when <name> ["," <name>]* ["(" <idn> ":" <type_designator> ")"] ":" <body>The expression must evaluate to a "oneof" or "maybe" object. The tag of this object is then matched against the names on the tag_arms. When a match is found, if a declaration exists in the arm, the value component of the object is assigned to the local variable idn. The matching body is then executed; the idn is defined only in that body. If no match is found, the body in the others arm is executed. When execution of the body completes, control continues at the statement after the tagcase.
In a syntactically correct tagcase statement, the following constraints are satisfied:
Here is an example:
x: oneof[none: null, some: int] ... tagcase x when none: ... when some(y: int): ... y+7 ... end