aboutsummaryrefslogtreecommitdiff
path: root/src/content/chapter2_flow_control/lesson09_alternative_patterns/text.html
blob: 10ad73154fad8187c9889b30199114534a8b53e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<p>
  Alternative patterns can be given for a case clause using the
  <code>|</code> operator. If any of the patterns match then the clause matches.
</p>
<p>
  When matching on multiple subjects there must be the same number of patterns
  as there are subjects. Try removing one of the <code>_,</code> sub-patterns to
  see the compile time error that is returned.
</p>
<p>
  If a pattern defines a variable then all of the alternative patterns for that
  clause must also define a variable with the same name and same type.
</p>
<p>
  Currently it is not possible to have nested alternative patterns, so the
  pattern <code>[1 | 2 | 3]</code> is not valid.
</p>