Re:Ruby adds experimental support for Rightward assignments
by rowanG077 on Saturday September 05, 2020 @01:02PM
(#24385048)
"=" is still equality. It's not an operator that compares two values. It's an operator that defines the left hand to be equal to the right hand. I feel like "=" for assignment is fine. For boolean comparison something like "=?" seems most clear, like asking a question whether the left and right hand side are equal.
[ Parent
| on HN ]
Re:Ruby adds experimental support for Rightward assignments
by scarmig on Saturday September 05, 2020 @04:43PM
(#24386711)
In imperative languages, assignment has a side effect of making the LHS equal to the RHS. But it's still different from equality, since variables can be reassigned
E.g.
a = 2
a = 3
2 = 3 //what???
Assignment is fundamentally part of the language execution model, which is entirely apart from anything related to mathematical equality. Even in languages where you can't rebind a variable name, it's still weird to use = as assignment, since it would have such different behavior than seemingly analogous operators like > and <.