Closed copygirl closed 12 years ago
x
gets the lower value in both cases. The compound version is compiled so that the assignment only happens when necessary (just like x ||= y
compiles to x || (x = y)
rather than x = x || y
).
x = 0
y = Math.random! * 10 - 5
x <?= y
always returns y
.
x = x <? y
on the other hand only returns y
when it's smaller than 0.
x <?= y
will return y, but assigns x correctly.
Oh, the return value. Yup, that's a bug.
(was x <?= y not the same as x = x <? y)
I'm not quite sure what exactly is going on here, but I expected these two to behave the same.