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

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.

主站蜘蛛池模板: 孙吴县| 临汾市| 山东省| 望都县| 古浪县| 贵德县| 大邑县| 岳池县| 武陟县| 睢宁县| 宁波市| 福安市| 黔西县| 都江堰市| 鄢陵县| 河北省| 阳山县| 金坛市| 霍山县| 道真| 平凉市| 维西| 当雄县| 广宗县| 山阳县| 淮北市| 拉孜县| 介休市| 永川市| 九江县| 南涧| 屯昌县| 永川市| 渝北区| 澎湖县| 高阳县| 保德县| 玛曲县| 安宁市| 寻乌县| 武胜县|