Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x <?= y should return x when x <= y #178

Closed
copygirl opened this issue Oct 15, 2012 · 4 comments
Closed

x <?= y should return x when x <= y #178

copygirl opened this issue Oct 15, 2012 · 4 comments
Labels

Comments

@copygirl
Copy link

(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.

@satyr
Copy link
Owner

satyr commented Oct 15, 2012

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).

@copygirl
Copy link
Author

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.

@vendethiel
Copy link
Contributor

x <?= y will return y, but assigns x correctly.

@satyr
Copy link
Owner

satyr commented Oct 15, 2012

Oh, the return value. Yup, that's a bug.

@satyr satyr closed this as completed in 7330542 Oct 15, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants