O'Reilly logo

Dart: Scalable Application Development by Ivo Balbaert, Sergey Akopkokhyants, Davy Mitchell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Collections and generics

All the collection classes that are implemented use generics very heavily. As discussed in Chapter 2, Advanced Techniques and Reflection, generics provide the type of object that a collection contains. Every attempt to add another type of element generates a static analysis warning. Generics in collections have the following advantages:

  • They help avoid class cast errors at runtime since we get the warnings during the static analysis time
  • They make the code cleaner, as there is no need to use casting operators and conditions to check types
  • They add to the runtime benefit only because the execution is done in the production mode. The code that is compiled to JavaScript does not check types and generics

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required