The Power of Generics : Swift


One of the most powerful features introduced in Swift was Generics. Generics are used to avoid duplication and to provide abstraction. The generic code allows you to write flexible, reusable functions and data types that can work with any type that matches the defined constraints. Swift standard libraries are built with generics code.¬†Swift’s ‘Array’ and…
Read more

Higher order functions in Swift


Higher-order functions are functions that can accept other function or closure as parameters. I’ll introduce some very useful higher-order functions. Those functions are Map, Filter, Reduce, Sorted, CompactMap, Chaining, Contains. Other new higher-order functions were introduced in Swift 4.2. Those functions are AllSatisfy, FirstIndex, LastIndex and RemoveAll. Map Map function can be used to loop…
Read more