- Hands-On Design Patterns with Swift
- Florent Vilmart Giordano Scalzo Sergio De Simone
- 98字
- 2021-07-02 14:45:01
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.
推薦閱讀
- 數據庫原理及應用教程(第4版)(微課版)
- Word 2010中文版完全自學手冊
- Effective Amazon Machine Learning
- SQL查詢:從入門到實踐(第4版)
- iOS and OS X Network Programming Cookbook
- Mastering Machine Learning with R(Second Edition)
- Sybase數據庫在UNIX、Windows上的實施和管理
- 深入淺出 Hyperscan:高性能正則表達式算法原理與設計
- R語言數據挖掘
- 大數據分析:數據倉庫項目實戰
- Mastering LOB Development for Silverlight 5:A Case Study in Action
- 智慧城市中的大數據分析技術
- 數據庫應用系統技術
- 數據指標體系:構建方法與應用實踐
- 數據挖掘算法實踐與案例詳解