- Mastering Swift
- Jon Hoffman
- 130字
- 2021-07-16 14:12:14
Mutability
For those who are familiar with Objective-C, you know that there are different classes for mutable and nonmutable collections. For example, to define a mutable array, we use the NSMutableArray
class, and to define a nonmutable array, we use the NSArray
class. Swift is a little different because it does not contain separate classes for mutable and nonmutable collections. Instead, we define whether a collection is constant (nonmutable) or a variable (mutable) by using the let
and var
keywords. This should seem familiar since, in Swift, we define constants with the let
keyword and variables with the var
keyword.
Note
It is good practice to create immutable collections unless there is a specific need to change the objects within the collection. This allows the compiler to optimize the performance.
- JavaScript修煉之道
- Debian 7:System Administration Best Practices
- 構建移動網站與APP:HTML 5移動開發入門與實戰(跨平臺移動開發叢書)
- 信息可視化的藝術:信息可視化在英國
- Python Deep Learning
- Hadoop+Spark大數據分析實戰
- 零基礎學Java(第4版)
- 零基礎輕松學SQL Server 2016
- 微信小程序項目開發實戰
- RabbitMQ Cookbook
- 用案例學Java Web整合開發
- HTML5+CSS3+jQuery Mobile APP與移動網站設計從入門到精通
- 深度探索Go語言:對象模型與runtime的原理特性及應用
- 現代C:概念剖析和編程實踐
- 黑莓(BlackBerry)開發從入門到精通