Chapter 3

Intro to Functional Swift

This chapter is dedicated to closures. I took courses from Udemy, Lynda, Treehouse, and YouTube. However, there wasn’t a single course that the instructor challenged herself to explain closures despite wide usage. As a result, including myself, students often turn into code monkeys. They simply copy off from the screen and Stack Overflow answers.

First, let me ask you a question. Have you heard about completion handlers. If you had any experience with networking with database, such as Facebook Login, you have. But, do you know how to design one? Do you know how to initialize objects using closures? Do you know the difference between escaping and autoclosures? Do you know what it means to capture self?

When I learned Swift as my first programming language, I had a tough time understanding closures. As I’ve been blogging for a while, I’ve discovered this isn’t the only problem of mine. It took me 3 months to completely understand closures. I don’t expect you to be comfortable with closures just by taking a couple lessons with me. However, your time to mastery will dramatically decrease because you are here with me.

As much as I want to this chapter to be digestible, I have to admit it. It is not easy. The process is analogous to riding a bicycle for the first time. Your parents might be able to give you a little push from the back. At the end of the day, you are the one paddling and succeeding. Expect you will fall from the bicycle many times. Those mental scars, however, will define who you are because many give up.

Throughout the chapter, I’ve attached a number of articles for you to study more. If you get stuck, you may refer to them and study until you get it. Do whatever it takes.