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

Would prefer Groovy's Elvis operator "?:" instead of "??" #4

Closed
HendrikJan opened this issue Mar 5, 2015 · 2 comments
Closed

Would prefer Groovy's Elvis operator "?:" instead of "??" #4

HendrikJan opened this issue Mar 5, 2015 · 2 comments

Comments

@HendrikJan
Copy link

a ?: b

looks more descriptive to me than

a ?? b

to me, because it contains both characters of the more verbose syntax

a ? a : b;
@seaneagan
Copy link
Contributor

The more verbose syntax is actually a == null ? b : a or equivalently a != null ? a : b. Personally I don't see an obvious expansion of a ?: b to either of those.

One other syntax to consider would be a else b. But ?? is more similar to ?..

@munificent
Copy link

If you look around, this same operator is spelled either ?? or ?: in a bunch of different languages. I don't think either one has a big majority. C# and Swift use ??, PHP and Groovy use ?:.

Personally, I prefer ??, in particular because it ties in nicely with Sean's suggestion about compound assignment in #6.

@gbracha gbracha closed this as completed Mar 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants