Trailing Closure Syntax
suggest changeWhen 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)
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents