Skip to content

Instantly share code, notes, and snippets.

@zidenis
Last active May 9, 2017 21:02
Show Gist options
  • Save zidenis/d04c2060ae1a405cebd105259c49cab7 to your computer and use it in GitHub Desktop.
Save zidenis/d04c2060ae1a405cebd105259c49cab7 to your computer and use it in GitHub Desktop.
runtimeType behaviour
void main() {
String s = "Dart";
print(s is String); // true
print(s.runtimeType); // String
Dart d = new Dart();
NotDart nd = new NotDart();
print(d is Dart); // true
print(nd is Dart); // false
print(nd is NotDart); // true
print(nd.runtimeType); // Dart
print(d.runtimeType == nd.runtimeType); // true
}
class Dart {}
class NotDart {
Type get runtimeType => Dart;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment