How to pin variables in patterns

Is there a way to use variables in a (case of)pattern as value not as part of the pattern? ( i think its called pinning )

1 Like

So you mean using a variable as something that should be matched in the pattern?

There isn’t a way to do that in a pattern directly, no, but you can use a guard to achieve the same thing instead perhaps.

2 Likes