December 2015
Intermediate to advanced
400 pages
13h 3m
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
Implicit declarations with integer values are always assumed to be Int by the compiler. However, you can create instances of the other integer types using explicit type declarations.
Listing 4.5 Declaring other integer types explicitly
... let ...
Read now
Unlock full access