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

Feature Request: Support ?? operator, and perhaps also ??! #18045

Closed
tfortes opened this issue Apr 5, 2014 · 2 comments
Closed

Feature Request: Support ?? operator, and perhaps also ??! #18045

tfortes opened this issue Apr 5, 2014 · 2 comments
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report type-enhancement A request for a change that isn't a bug

Comments

@tfortes
Copy link

tfortes commented Apr 5, 2014

In Dart, you often have to type:

  String aTextValue = getText();
  String y = (aTextValue != null) ? aTextValue : 'Default';

...but the null-coalescing operator ?? simplifies this by returning LHS if LHS is non-null and RHS otherwise.

  String y = aTextValue ?? 'Default';

Going one step further, we could also add the ??! operator that returns null if LHS is null, and RHS otherwise.

Element child = getChild();
Element parent = child ??! child.parent;

[The operator names are debatable of course]

@kevmoo
Copy link
Member

kevmoo commented Apr 5, 2014

Removed Type-Defect label.
Added Type-Enhancement, Area-Language, Triaged labels.

@kevmoo
Copy link
Member

kevmoo commented Apr 5, 2014

Added Duplicate label.
Marked as being merged into #1236.

@tfortes tfortes added Type-Enhancement area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report labels Apr 5, 2014
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed priority-unassigned labels Mar 1, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

2 participants