Chapter 2 - about checking type

The next chapter (3) will cover this. The num type could be a double at runtime, so the static analysis/compiler will preemptively complain. When you enclose the statement in a conditional block with the is type test operator, to test for an int, the compiler can affirm .isEven function will be called on an int value

num is for numeric values whose types are not known at compile time. It can store a int or double

The num type is derived from Object
The int and double types are derived from num, so they all belong to it.

num someNumber = 3;
print(someNumber is Object); // True for all values in Dart
print(someNumber is num); // True
print(someNumber is int); // True
print(someNumber.runtimeType); // int
3 Likes