Created
March 17, 2019 07:33
-
-
Save benznest/cc85152097c120031c0622872732fd59 to your computer and use it in GitHub Desktop.
Null conditional in 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
class Spacecraft{ | |
Astronaut astronaut; | |
} | |
class Astronaut{ | |
String name; | |
} | |
main(){ | |
Spacecraft sc = Spacecraft (); | |
String astronautName = sc?.astronaut?.name ?? "Neil Armstrong"; | |
print(astronautName); // ""Neil Armstrong" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment