Get immediate access to this and over 1,500+ other videos and books.

Boost your skills with a raywenderlich.com Beginner subscription. With over 60+ video courses and our core foundational programming books bundled in one subscription, it’s simply the best investment you can make in your development career.

Map & Filter Collections

This video was last updated on Jun 21 2022

Put anonymous functions to use by using the map function and the filter function on Lists to both transform and filter values.

Contributors

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a raywenderlich.com Professional subscription.

Now that you have a good idea at how to work with anonymous functions, it’s time to build on that by working with a list. A list comes with two different functions called map and filter. We will start with the map function.

var names = [
    { 'firstName': 'Frank', 'lastName': 'Oz' },
    { 'firstName': 'Jim', 'lastName': 'Henson' },
    { 'firstName': 'Stan', 'lastName': 'Winston' }
];
var fullNames = 
var fullNames = names.map();
var fullNames = names.map((item) {

});
final firstName = item['firstName'];
final lastName = item['lastName'];
if (firstName != null && lastName != null) {

}
return '$firstName $lastName';
print(fullNames);
var muppetCreators = names.where((item) {

});
final lastName = item['lastName'];
if (lastName != null) {
    return (lastName == 'Oz' || lastName == 'Henson');
}
return false;
print(muppetCreators);

Reviews

Comments