And again we replace our cut-and-paste for-loop with a reusable function that captures the goal. We save some code, but it’s more than that. We can compose filters and maps to create more interesting things in highly readable ways.
The goal of using
filterthis way is to make your code easier to read, understand, and debug. It gets the boilerplate out of the way and leaves you with the key parts of what you’re trying to do.
This is so much nicer in Swift than Objective-C because of the concise syntax.
Stay up-to-date by subscribing to the Comments RSS Feed for this post.