Skip to content

Instantly share code, notes, and snippets.

@MarkThalman
MarkThalman / MapFilterReduce.md
Last active September 28, 2018 02:23
Map, Filter, Reduce Quick Reference

Swift Guide to Map Filter Reduce

Next time you find yourself looping over a collection check if you could use map, filter or reduce:

  1. map returns an Array containing results of applying a transform to each item.
  2. filter returns an Array containing only those items that match an include condition.
  3. reduce returns a single value calculated by calling a combine closure for each item with an initial value.

map Full: