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

Swift collection types

A collection is a group or store of data that has a shared significance. Swift provides two native collection types for storing data. These collection types are known as arrays and dictionaries. An array will store the data in an ordered list, while a dictionary will store the data in an unordered list. In an array, we access the data by the location (index) in the array, while the data in a dictionary is accessed using a unique key that is associated with the value we want.

The data stored in a Swift collection is required to be of the same type. This means, as an example, that we are unable to store a string and an int in the same array. Since Swift does not allow us to mismatch data types in a collection, we can be certain of the data type when we retrieve data from a collection. This is another feature, which on the surface might seem like a shortcoming, but is actually a design feature that helps eliminate common programming mistakes.

主站蜘蛛池模板: 剑川县| 临邑县| 广德县| 香格里拉县| 临高县| 保定市| 日照市| 宾川县| 永吉县| 阳山县| 洛浦县| 余江县| 古浪县| 通辽市| 竹溪县| 蒲城县| 上饶市| 营山县| 拉萨市| 洪洞县| 多伦县| 宣城市| 衢州市| 兖州市| 长寿区| 湛江市| 泰顺县| 新晃| 贞丰县| 八宿县| 中超| 和龙市| 故城县| 铜川市| 大邑县| 阳东县| 青阳县| 海原县| 隆昌县| 上虞市| 安多县|