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

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.

主站蜘蛛池模板: 顺昌县| 巴彦县| 尉犁县| 墨脱县| 长丰县| 浦北县| 甘德县| 洮南市| 凤台县| 仙游县| 三门县| 望江县| 海伦市| 余姚市| 云霄县| 灌南县| 蚌埠市| 清水河县| 北宁市| 鄂托克旗| 满城县| 衡南县| 庆元县| 和顺县| 定州市| 太原市| 新竹市| 宜黄县| 绥芬河市| 尉氏县| 革吉县| 阜宁县| 宝兴县| 鄂伦春自治旗| 台山市| 庄浪县| 绍兴市| 富源县| 忻州市| 桐柏县| 黑龙江省|