Extending the null-coalescing operator #8669
Unanswered
ActivistInvestor
asked this question in
Language Ideas
Replies: 1 comment 1 reply
-
this becomes heavily syntactically ambiguous. For example, this is already legal today: |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
There may be good reasons why this may not be feasible, but I would find it helpful if the null-coalescing operator were extensible.
So for example, Instead of
int x = y != null ? 1 : 0;
it could use ?? thusly:
int x = y ?? 1 : 0;
What that effectively means is that
y ??
is shorthand fory != null
, and where the result and right-side operand of ?? is inferred by the context and/or the types on the right side.Beta Was this translation helpful? Give feedback.
All reactions