4 ms·
Elixir uses the “pin operator” “Use the pin operator ^ when you want to pattern match against a variable’s existing value rather than rebinding the variable.”
by heisenzombie 6y ago
Elixir uses the “pin operator”
“Use the pin operator ^ when you want to pattern match against a variable’s existing value rather than rebinding the variable.”
iex> not_found = 404
404
iex> ^not_found = 200
** (MatchError) no match of right hand side value: 200
https://elixir-lang.org/getting-started/pattern-matching.html#the-pin-operator https://elixir-lang.org/getting-started/pattern-matching.htm...
- pfalcon 6y agoExactly, Elixir is usually the only example given. So, how it makes sense to blame Python here is unclear. There's a proposal to add similar "sigils" to Python pattern matching, it just didn't make it yet.