Generic collections and the types they contain

Dart generic types are reified, which means that they carry their typeinformation around at runtime. For example, you can test the type of acollection:

  1. var names = List<String>();
  2. names.addAll(['Seth', 'Kathy', 'Lars']);
  3. print(names is List<String>); // true

Note: In contrast, generics in Java use erasure, which means that generic type parameters are removed at runtime. In Java, you can test whether an object is a List, but you can’t test whether it’s a List<String>.