Use Higher-Order Functions
Another defining feature of a functional language is making functions first-class citizens. That means that not only is it possible to have functions attached to objects or structures or enums (or even inside of functions), it is also possible to have variables or constants that point to functions, to pass functions into other functions, and to return functions from functions. It is not something languages like Java can do at all. Objective-C made great strides with block syntax, and has always had use of C functions, but Swift provides even more power and much clearer syntax for dealing with functions.
The point of this power and clarity is to attack problems at a higher conceptual level. Instead of thinking about ...
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