3 ms·
I can think of a few cases where I want: if x == y == z:
by klodolph 7y ago
I can think of a few cases where I want:
if x == y == z:
- nogridbag 7y agoI always found prefix notation in Clojure to be really elegant for a lot these cases that are odd in other languages: (= x y z)
- ramshorns 7y agoThis is a bit like something you can do in C, almost by accident as a bonus language feature. x = y = z = 4; But I think this is assignment expressions which were controversial in Python or something.
- mark-r 7y agoNot anymore, check out the walrus operator.
- sk0g 7y agoYeah in Python you can do, say, a = b = [] But then the two lists are the same, and appending to one appends to the other. Not particularly useful.
- Ragib_Zaman 7y agoIt's useful when the object being assigned to those variables are literals instead of reference types, which in my experience is most of the time when you want to do the simultaneous assignment. When you do want to do reference types, you can do a,b = [], [].