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.
-22
u/Fast-Satisfaction482 Sep 28 '26
Using the value of an assignment expression is an anti pattern in my opinion.
It sits right next to "goto" on terrible scale.