Posted at

Swiftでmutable arrayにできないとき

More than 5 years have passed since last update.

格納するオブジェクト型を指定しないとimmutableなarrayになるらしい。

let array0 = [] // immutable

var array1 = [] // immutable
var array2 = ["1", "2"] //mutable
var array3: String[] = [] // mutable