Functional Swift
The really cool new stuff in Swift is all functional programming features. There are two main facets to Swift’s version of functional programming: managing mutability, and first-class functions and closures.
Managing Mutability
In programming, you can’t avoid mutable state. It’s a fact. Most of the time, it’s the reason that we’re using a computer. For example, say I’m using a program called Atom to write a blog post. There wouldn’t be any point in using Atom if I couldn’t modify the file I’m writing.
But mutable state makes things complicated. In a large, complex software system, code that avoids mutating things is usually easier to understand, less prone to errors and unexpected side effects, and easier to interact with. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access