Why is it called a “Closure” anyway? A Swift Conceptual Look.

Bottle with cork

What’s in a name? If a programming language comes with a named feature, you can be pretty sure it was named that way for a reason. It’s a safe bet that the language designers were purposeful in their naming, so if you can figure out that essential “Why’d they name it that?” question, you might […]

Why Do We Need to Annotate Escaping Closures in Swift?

Why Do We Need to Annotate Escaping Closures?

My last entry on escaping closures ended up having way more interaction than I anticipated! It goes to show that you never know what the impact of a piece of writing will have. But that’s a different story… :] Several readers commented here and on Medium with the question, “Why? Why do we need to […]

What in the World is an “Escaping Closure” in Swift?

Escape

If you’re mostly in the business of coding up closures to pass off to other functions as callbacks, you may not have run into the concept of an “escaping closure” yet. When you step out of the role of consuming other peoples’ APIs in to the realm of creating your own (and you do this […]

Resolving “Variable used within its own initial value” Error in Swift

While experimenting with a few things today, I experienced this compiler error: Variable used within its own initial value Let me describe the situation I was in… I was playing (in a playground, no less) with closures, trying to mimic some behavior that I’ve recently learned about in Scala.  Essentially, I was trying to implement a factorial […]