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

Destructuring tuples

There is a simple method to access tuple values. Take, for example, the size pair, as follows:

let size = (width: 200, height: 400)
let (w, h) = size
let (width, _) = size

In the preceding example, we initialize a tuple on the first line. On the second line, we destructure both parameters as w and h. On the last line is what we call a partial destructuring: when you're only interested in one part of the tuple, you can extract only a part of it. This is useful when dealing with large tuples.

主站蜘蛛池模板: 金昌市| 兴化市| 富源县| 巴马| 遵化市| 泾阳县| 博兴县| 松原市| 呼伦贝尔市| 龙口市| 汉沽区| 化州市| 七台河市| 于田县| 商水县| 晋城| 城固县| 东乡族自治县| 当雄县| 化隆| 滕州市| 龙陵县| 兴和县| 宝应县| 长乐市| 德令哈市| 广德县| 东平县| 隆德县| 中卫市| 蓝田县| 油尖旺区| 新晃| 恩施市| 金沙县| 六盘水市| 汉川市| 阜康市| 廊坊市| 巴林左旗| 威宁|