From the course: Learning Higher-Order Functions with Swift

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Map

Map

From the course: Learning Higher-Order Functions with Swift

Start my 1-month free trial

Map

- {Male Speaker} So now we're going to get a little more serious about these higher order functions. We're going to get into map. This one is a little bit different conceptually. The sort and the 4H these are things we've dealt with before but map this one's going into unchartered waters as they say. So we want to consider map whenever you have a collection of something, so an array of something, and you want to convert it to a collection of something else, an array of something else, but of the same size. So you have ten strings and you would like to have an array of Ints of the lengths of all those ten strings. So it's still going to have ten values in it but it could be anything else. You might take an array of ten names and map it to an array of ten places of popularity for that name. Or you might have 42 instances of addresses and you want to convert those to 42 instances of locations with coordinates, latitude and longitude. You can think of it as convert but don't just…

Contents