Day 7 of 100 Days of Swift

Days 1 to 12 of the “100 Days of Swift” course make up the “Introduction to Swift” section.

Day 7‘s lesson covered closures (part 2 of 2). The specific topics were: using closures as parameters when they accept parameters, using closures as parameters when they return values, shorthand parameter names, closures with multiple parameters, returning closures from functions, and capturing values.

Thoughts about Day 7

I started work on Day 7 (part 2 of 2 on closures) by re-watching the videos for Day 6 (part 1 of 2 of closures) to re-expose myself to the fundamentals of closures before working through the advanced closures concepts.

For all six sections of Day 7’s lesson I watched the video, read the video transcript, read the Optional readings, and did the Test.

What I did differently today from the previous Days was to enter and execute ALL the example closures code from the videos, Optional readings, and Tests. I read each code example line-by-line and did my best to follow the code example’s logic in my mind and when needed, on paper.

Because of this slow line-by-line review of the closure code examples it took me four hours to complete the Day 7 lesson.

I think the time invested in the line-by-line studying of the code paid off because the syntax and usage of closures now makes sense to me (as compared to my first attempt through the Day 7 lesson yesterday) and I appreciate and see the value of closures.

My Day 7 notes written in my notebook are mostly of variable and constant names from the code examples and the penciled values assigned to them as I executed code examples mentally.

The one “note to self” that I did capture was for section 6. Capturing values‘s Optional reading “Why do Swift’s closures capture values?”

At the bottom of the Optional reading is a link to a post by Oliver Halligon titled “Closures Capture Semantics: Catch them all!” The post is about the Swift language’s memory management of closures. I started reading the post only to find that some of the given examples used the concept of classes, which the 100 Days of Swift doesn’t cover until Day 10, so I noted to myself to read the “Closures Capture Semantics: Catch them all!” post after completing the Day 10 lesson.


Today’s total study time: 4 hours

100 Days of Swift cumulative study time: 19 hours