-
サマリー
あらすじ・解説
Okay, so I'm live here with 52 weeks of Swift, Episode Seven closures, going to talk about how they work with Swift. And let's go ahead and get started, I'm going to share my screen. Let's go ahead and get this thing going here. So to start with, in Swift here, we can see that closures are self contained blocks of functionality that get passed around. And so in the world of distributed computing, which is really the world we live in with cloud computing, it's really a great strategy to have some kind of closure in your codebase. Because really, you can just pass a piece of code around, it's got everything it needs to do, its work, and then it does its work. And then it returns back result or just goes away because it's done working. So here, we can see here that you can see that there's global and nested functions. So typically, that's how the closure works, right is that you have a function with outer scope. And as an inner function, it retains that state, and then it goes through and it does its work.