Swift Language Trailing Closure Syntax


Example

When the last parameter of a function is a closure

func loadData(id: String, completion:(result: String) -> ()) {
    // ...
    completion(result:"This is the result data")
}

the function can be invoked using the Trailing Closure Syntax

loadData("123") { result in
    print(result)
}