Book Image

Mastering Dart

By : Sergey Akopkokhyants
Book Image

Mastering Dart

By: Sergey Akopkokhyants

Overview of this book

Table of Contents (19 chapters)
Mastering Dart
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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