Created
August 2, 2019 01:53
-
-
Save ThinkDigitalSoftware/2012b9264ee9ec79e8c9800d42d3fbef to your computer and use it in GitHub Desktop.
Switch statement using runtimeType 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
main(){ | |
var a = B(); | |
switch(a.runtimeType){ | |
case A:{ | |
print ("A"); | |
break; | |
} | |
case B:{ | |
print ("B"); | |
break; | |
} | |
default: | |
{ | |
print ("No match. ${a.runtimeType}"); | |
} | |
} | |
} | |
class A {} | |
class B {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment