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

Declaring tuples

Tuples can hold any number of values, from any number of types. You can declare a tuple with the same types—let's say a 2D point in Double:

let origin = (0.0, 0.0)

You can also name the parameters, as follows:

let point = (x: 10.0, y: 10.0)

The two forms are equivalent, but you may want to use the named version, for readability reasons. If you're referencing a size, for example, the tuple would more accordingly be named (width: Double, height: Double). For obvious reasons, this helps to provide a better understanding of your code.

主站蜘蛛池模板: 宝坻区| 黎川县| 广水市| 普格县| 洞口县| 马龙县| 自治县| 临城县| 资阳市| 射洪县| 奇台县| 合肥市| 富锦市| 华蓥市| 阜城县| 南召县| 酉阳| 岳阳市| 云南省| 洪泽县| 自贡市| 红桥区| 通化市| 新宁县| 长宁县| 隆安县| 台江县| 峨边| 乌拉特前旗| 克拉玛依市| 无锡市| 甘南县| 涿鹿县| 金阳县| 松溪县| 辽宁省| 林周县| 宁海县| 乃东县| 勃利县| 上虞市|