- 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.
推薦閱讀
- GitHub Essentials
- 數(shù)據(jù)存儲架構(gòu)與技術(shù)
- Redis應用實例
- 云計算服務保障體系
- 數(shù)據(jù)庫原理與應用(Oracle版)
- Google Cloud Platform for Developers
- 大數(shù)據(jù)技術(shù)原理與應用:概念、存儲、處理、分析與應用
- 菜鳥學SPSS數(shù)據(jù)分析
- 大數(shù)據(jù)與機器學習:實踐方法與行業(yè)案例
- MySQL數(shù)據(jù)庫實用教程
- Machine Learning for Mobile
- 數(shù)據(jù)會說話:活用數(shù)據(jù)表達、說服與決策
- 數(shù)字孿生
- Applying Math with Python
- 工業(yè)大數(shù)據(jù)分析實踐