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

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.

主站蜘蛛池模板: 平山县| 烟台市| 固阳县| 天水市| 开鲁县| 军事| 比如县| 裕民县| 武宣县| 丰都县| 龙江县| 大港区| 日土县| 铜鼓县| 安达市| 鄂温| 香格里拉县| 富宁县| 泌阳县| 海原县| 三明市| 壤塘县| 大城县| 嵊州市| 怀化市| 普洱| 盐山县| 大方县| 邯郸县| 将乐县| 孟州市| 和田市| 阿坝县| 彭山县| 波密县| 恭城| 安新县| 芜湖县| 广宁县| 广南县| 治多县|