1.

ASCII Legacy Property ListQuestion: What do you understand about training closure syntax in ios Swift?

Answer»

Many iOS Swift functions accept MULTIPLE parameters, the last of which is a closure. Trailing closure syntax is a small amount of syntactic sugar that makes READING and writing common CODE easier. 

For example, CONSIDER the following code snippet:

FUNC RunClosureAfterGreeting(name: String, closure: () -> ()) { print("Hi, \(name)!!!") closure()}

Instead of the above code snippet, we can write the following code (which is way cleaner than the previous one):

RunClosureAfterGreeting(name: "Sonia") { print("The closure has been run")}


Discussion

No Comment Found