May 8, 2020
There's a bit in the Mel Brooks movie "High Anxiety" where the chauffeur meets Mel at the airport and bends down to pick up Mel's trunk.
The chauffeur struggles while saying, "I got it, I got it, I got it."
He then drops it and says, "I ain't got it."
But it's not a comedy unless he tries again, saying, "I got it, I got it, I got it."
He then drops the trunk again saying, "I ain't got it."
For many of us, this is map().
We learn it - and we think we got it. It seems dumb to go to all this fuss for just another way to write a for-loop so we drop it and say, "I ain't got it."
But then some smart person writes a blog post or a book so we read it and nod and think, "I got it".
And then it comes time to write our own code and we realize, "I ain't got it."
Well, I think that finally, "I got it" and I hope that the explanation I've written in Chapter 5 of my Functional Programming book will help you see map() as a design pattern and not as a one-off implementation in Swift's Arrays.
If you own the book, the chapter 5 update is available for free on Gumroad.
I hope after reading this chapter you'll think, "I got it".