Swift Functional Programming(Second Edition)
上QQ阅读APP看书,第一时间看更新

Immutability

Swift makes it easy to define immutable values--in other words, constants--and empowers FP, as immutability is one of the key concepts in FP. Once constants are initialized, they cannot be altered or mutated. Although it is possible to achieve immutability in languages such as Java, it is not as easy as Swift. To define any immutable type in Swift, the let keyword can be used no matter if it is a custom type, collection type, or a Struct/enum type.