官术网_书友最值得收藏!

Creating an array with initial values

Arrays can have initial values when they are created. Let's see how this would look by entering the following in Playgrounds:

let integers2 = [54, 29]  

Your code will now look like this:

The array that we just entered uses type inference to declare the data type of the array using its initial values. In this case, Swift understands that it is an array of ints because the values we entered are integers. In addition, when we use a constant (let) on an array, we are telling Swift that the array is an immutable array, which means that the contents or size cannot change once it is instantiated.

主站蜘蛛池模板: 上犹县| 左权县| 襄汾县| 江陵县| 乐山市| 县级市| 江孜县| 工布江达县| 嘉黎县| 呈贡县| 宁海县| 曲麻莱县| 京山县| 昌平区| 台南市| 定远县| 开远市| 木兰县| 平安县| 巴林左旗| 惠东县| 北辰区| 莱芜市| 盈江县| 东城区| 玉山县| 宜城市| 防城港市| 明星| 乐至县| 油尖旺区| 济源市| 什邡市| 手游| 娱乐| 华坪县| 秦安县| 隆德县| 株洲县| 阿拉善左旗| 扬中市|