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

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.

主站蜘蛛池模板: 湘潭县| 临海市| 福泉市| 延川县| 六安市| 合阳县| 翼城县| 河源市| 洪雅县| 山西省| 吉隆县| 金门县| 江油市| 吉木萨尔县| 兴义市| 普兰店市| 湘阴县| 天气| 安吉县| 嘉禾县| 齐河县| 博爱县| 中方县| 菏泽市| 高安市| 达拉特旗| 婺源县| 肇州县| 大安市| 定日县| 临武县| 兰溪市| 尉犁县| 泸定县| 阳信县| 义乌市| 伽师县| 临朐县| 绥德县| 珠海市| 如皋市|