Chapter 5. Types

Up to this point, we have not discussed types in any detail. We have been able to delay the discussion until now because Dart is optionally typed. In this chapter, we shall describe Dart’s types, filling in many gaps in the story we have presented so far. We begin by explaining optional typing, perhaps Dart’s most unusual characteristic.

5.1 Optional Typing

As noted in the introduction, a language is optionally typed if, and only if:

• Types are syntactically optional.

• Types have no effect on runtime semantics.

The latter point is far more significant than the former. Those accustomed to traditional statically typed languages may find this disconcerting at first. The point is subtle but crucial. It is a cornerstone of the ...

Get The Dart Programming Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.