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

Null coalescing operator #97

Open
JoshWillik opened this issue Nov 29, 2014 · 3 comments
Open

Null coalescing operator #97

JoshWillik opened this issue Nov 29, 2014 · 3 comments
Milestone

Comments

@JoshWillik
Copy link

I have a couple of points about the null coalescing operator, ??.

Firstly, why isn't it still || like vanilla JS and the rest of the programming languages[1]?
Changing it just for the sake of change just introduces confusion is not an improvement, IMHO.

Secondly, the ruby-esque ||= operator would be amazing.

a ||= b

becomes

a = a || b

(this can be ??= if you're quite set on keeping the ??)

[1] Except the unruly PHP

@alongubkin
Copy link
Owner

|| doesn't work anymore because of http://spiderlang.org/#code-safety-logical-operators-consistency

Additionally, the ?? operator checks only for undefined or null, and not all falsy values (0, false, etc).

About ??= - definitely.

@alongubkin alongubkin added this to the 0.1.3 milestone Nov 29, 2014
@M-Zuber
Copy link

M-Zuber commented Nov 30, 2014

Am I correct in understanding that ?? based off of the c# ??
Either way the idea of ??= is a must

@alongubkin
Copy link
Owner

@M-Zuber Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants