- Hands-On Design Patterns with Swift
- Florent Vilmart Giordano Scalzo Sergio De Simone
- 99字
- 2021-07-02 14:45:01
Declaring tuples
Tuples can hold any number of values, from any number of types. You can declare a tuple with the same types—let's say a 2D point in Double:
let origin = (0.0, 0.0)
You can also name the parameters, as follows:
let point = (x: 10.0, y: 10.0)
The two forms are equivalent, but you may want to use the named version, for readability reasons. If you're referencing a size, for example, the tuple would more accordingly be named (width: Double, height: Double). For obvious reasons, this helps to provide a better understanding of your code.
推薦閱讀
- 數據庫基礎教程(SQL Server平臺)
- MySQL高可用解決方案:從主從復制到InnoDB Cluster架構
- 數據挖掘原理與實踐
- 使用GitOps實現Kubernetes的持續部署:模式、流程及工具
- 工業大數據分析算法實戰
- 數據化網站運營深度剖析
- Mastering Machine Learning with R(Second Edition)
- Spark大數據編程實用教程
- 視覺大數據智能分析算法實戰
- Internet of Things with Python
- 云工作時代:科技進化必將帶來的新工作方式
- 從Lucene到Elasticsearch:全文檢索實戰
- Visual Studio 2012 and .NET 4.5 Expert Development Cookbook
- 領域驅動設計精粹
- Practical Convolutional Neural Networks