Pin Pattern

The @ pattern indicates a pinned identifier. This means that the identifier cannot be rebound to a new value. In this example, we encounter an error when trying to rebind a pinned identifier.

a = 1 a = 2 @a = 3

This is useful when we want to match a value against the value bound to an identifier. In this example, we check if the age matches the value of the age variable. Note that in the second branch, the age identifier would be rebound to the value in the tuple.

xenia = ("Xenia", 42) age = 42 match xenia { (_, @age) -> true, (_, age) -> false }

© 2024 ouzu