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

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.

主站蜘蛛池模板: 澄城县| 通州区| 大渡口区| 罗江县| 莱芜市| 南召县| 突泉县| 信宜市| 肇源县| 万山特区| 新邵县| 汾西县| 图木舒克市| 富平县| 辉南县| 南部县| 虹口区| 长寿区| 东源县| 延长县| 新津县| 崇州市| 沽源县| 正安县| 乌鲁木齐市| 建始县| 哈密市| 河北省| 磴口县| 九台市| 鸡西市| 隆德县| 贵德县| 临夏市| 岳池县| 专栏| 镶黄旗| 南溪县| 武宁县| 怀集县| 宁安市|