Created
January 23, 2020 16:42
-
-
Save AlexVegner/ba353b1fe09cee016da0798d9ee296fd to your computer and use it in GitHub Desktop.
dart_null_check_operators.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| String a; // null | |
| if (a == null) { | |
| a = 'Hello'; | |
| } | |
| // equivalent to | |
| a ??= 'Hello'; | |
| // equivalent to | |
| a = a ?? 'Hello'; | |
| a = null; | |
| print(a?.length); // print null | |
| print(a?.length ?? 0); // print 0 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment