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.

Higher-order functions on dictionaries

Higher-order functions on dictionaries

From the course: Learning Higher-Order Functions with Swift

Start my 1-month free trial

Higher-order functions on dictionaries

- [Instructor] So now we're going to talk about calling higher-order functions on Dictionaries. So we talked about it on Arrays. We talked about it on sets. Now we're going to talk about it on Dictionaries. So, the parameter that's passed into your closures from a Dictionary higher-order function is a tuple. We've talked a little bit about tuples. On a Dictionary, it's simply two values: key and a value. The things that are returned vary as we've seen before. Filter returns a Dictionary with the items filtered out of it. Sort returns an Array, so you have to look at the return types. Let's look at a couple examples. So back in Xcode I'm going to delete everything. Goodbye to our beloved names Array and I'm going to create a new names. "Let names =" but this is going to be a dictionary so we have "LSU" and the name is "Tigers" We have "UNT": "Eagles" these are the mascots and then we have "UTEP" which is the "Miners" as in digging in the ground not under a certain age. So now we're…

Contents