- 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.
- Node.js Design Patterns
- 工程軟件開發技術基礎
- 從程序員到架構師:大數據量、緩存、高并發、微服務、多團隊協同等核心場景實戰
- Mastering Kali Linux for Web Penetration Testing
- 深度強化學習算法與實踐:基于PyTorch的實現
- Flux Architecture
- JavaScript 程序設計案例教程
- Learning Raspbian
- Apache Spark 2.x for Java Developers
- 愛上micro:bit
- HTML5秘籍(第2版)
- Practical Game Design with Unity and Playmaker
- 21天學通C++(第5版)
- Django 3.0應用開發詳解
- Docker:容器與容器云(第2版)