Swift Higher Order Functions

Here is what I like about Swift the most… it forces me to think in terms of what I can only describe as decoupled behavior. Behavior or implementation that doesn’t depend on any specific type. This can be clearly observed with higher order functions, protocol oriented programming or just Swift in general.

So what are they? Higher order functions are functions that take other functions as parameters. And even though the implementation of these functions can be, as any implementation, verbose and easily replicated, the advantage of using higher order functions is the fact that they promote a much succinct and easier to understand code by eliminating clutter. Some of these functions even have a default behavior (sort(_:) for example will sort elements in ascending order) which is very useful.

Continue reading “Swift Higher Order Functions”

Swift Higher Order Functions