| Start |
|---|
| Introduction with advance functions Let's take an scenario to understand advance function in better way, Map Function: Use map to loop over a collection and apply the same operation to each element in the collection. The map function returns an array containing the results of applying a mapping or transform function to each item. Flat-Map Function: The simplest use is as the name suggests to flatten a collection of collections. Filter Function: Use filter to loop over a collection and return an Array containing only those elements that match an include condition. Reduce: Use reduce to combine all items in a collection to create a single new value. Swift 2.3:- Swift 3:- |
| Flatten multidimensional array To flatten multidimensional array into single dimension, flatMap advance functions is used. Other use case is to neglect nil value from array & mapping values. Let's check with example:- Suppose We have an multidimensional array of cities & we want to sorted city name list in ascending order. In that case we can use flatMap function like:- Preparing a single dimensional list from multidimensional array, For sorting array values, we can use chaining operation or sort flatten array. Here below example showing chaining operation, |
Read Article
https://develop.horje.com/learn/1434/reference