A tuple pattern has the form (p1, p2, … pn)
where p1
through pn
are patterns. The pattern matches if the scrutinee is a tuple of the same arity as the pattern and p1
through pn
match against the elements of the tuple. The pattern (p)
is the same as the pattern p
, and the pattern ()
matches the literal value ()
of the trivial type {()} (both pronounced “unit”).
For example, this expression evaluates to 4
: