Swift’s god like functions: map, filter, reduce, flatmap.


Map use to iterate over a collection and returns an array containing the results of mapping the given closure over the sequence’s elements.

example of map


Another palatable method use to iterate over collection and returns the array containing only those elements that match the condition.

example of filter


This returns a single value resulted by combining all values from collection.

example of reduce


In simple words flatmap flattens the collection of collection.

example of flatmap



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store