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

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.

主站蜘蛛池模板: 精河县| 进贤县| 远安县| 凤山市| 江门市| 静乐县| 仪陇县| 葫芦岛市| 浪卡子县| 衡南县| 贵南县| 曲沃县| 枣庄市| 宣恩县| 秀山| 松原市| 海阳市| 安岳县| 瑞丽市| 博湖县| 宁陕县| 正镶白旗| 汉寿县| 个旧市| 鹤庆县| 淮滨县| 象山县| 那坡县| 射洪县| 临海市| 苏尼特左旗| 密山市| 新晃| 千阳县| 全州县| 安福县| 承德县| 剑川县| 永吉县| 洪江市| 兰州市|