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: "Danial") {
print("The closure has been run")
}