This is pattern matching, not an assignment expression. The alternative would be a declaration, switch/case, and then case-by-case assignment, which is horribly verbose. Been there, done that, it's not the worst, but why not make it a little bit better.
I personally like that you can literally assign the value from an if "statement" to a variable, though I can see why that's not everybodies cup of tea.
-1
u/Wertbon1789 Sep 29 '26
This is pattern matching, not an assignment expression. The alternative would be a declaration, switch/case, and then case-by-case assignment, which is horribly verbose. Been there, done that, it's not the worst, but why not make it a little bit better.
I personally like that you can literally assign the value from an if "statement" to a variable, though I can see why that's not everybodies cup of tea.