escaping closure and closure
Closures are self-contained blocks of functionality that can be passed around and used in your code.
let greeting:(String) -> () = { name in
print("Hi, \(name)!")
}
birthday("Bebo")
- An escaping closure is a closure that’s called after the function it was passed to returns. In other words, it outlives the function it was passed to.
- A non-escaping closure is a closure that’s called within the function it was passed into, i.e. before it returns.
Comments
Post a Comment