Feature Request: Support ?? operator, and perhaps also ??! #18045
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
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]
The text was updated successfully, but these errors were encountered: