dart-lang / dart-lang/language
"if not null" operators
- Dominant language
- TeX
- Stars
- 2.9k
- Forks
- 239
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 14
Description
Dart supports "if null" access and assignment operators — `??`, `??=`.
Equivalent "if not null" operators would also be useful, particularly when non-nullable types land (https://github.com/dart-lang/language/issues/110). They would allow concise use of nullable variables in a similar manner to quiver's `Optional`. E.g., instead of:
```
Optional foo;
foo = foo.transform(changeFoo);
final bar = foo.transform(fooToBar);
```
nullable variables could be used:
```
Foo? foo;
foo ?!= changeFoo(foo);
final bar = foo ?! fooToBar(foo);
```
Contributor guide
Research direction
Start with the proposed `?!` and `?!=` examples in this issue, then read language issue #110 for the non-nullable-type context. Compare the requested behavior with Dart's existing `??` and `??=` operators and determine whether the syntax and semantics can be specified. Done means the language-design question has an agreed decision.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100