November 2016
Intermediate to advanced
480 pages
14h 42m
English
You created instances of Int in Chapter 2, where you learned that you can declare a type explicitly or implicitly.
Listing 4.4 Declaring Int explicitly and implicitly
...
print("The maximum value for a 32-bit unsigned integer is \(UInt32.max).")
print("The minimum value for a 32-bit unsigned integer is \(UInt32.min).")
let numberOfPages: Int = 10 // Declares the type explicitly
let numberOfChapters = 3 // Also of type Int, but inferred by the compiler
The compiler always assumes that implicit declarations with integer values are of type Int. However, you can create instances of the other integer types using explicit type declarations.
Listing 4.5 Declaring other integer types explicitly
... ...
Read now
Unlock full access