Hands-On Design Patterns with Swift
上QQ阅读APP看书,第一时间看更新

Arrays

Unlike in Objective-C, a Swift array can only hold elements of the same type, and it's a value type.

The following code declares an Array container of three Int types,  1, 2, and 3:

let ints = [1,2,3] // Array<Int> or [Int]

As an example, if you wanted them to be Doubles, you could easily force the type on it:

let doubles: [Double] = [1,2,3]