Trailing Closure Syntax
suggest changeWhen the last parameter of a function is a closure
func loadData(id: String, completion: (String) -> Void) {
completion("This is the result data")
}
The function can be called with trailing closure syntax. Swift 3 and later require the id label. Swift 2 omitted it, and a closure type could spell the parameter label as result.
loadData(id: "123") { result in
print(result)
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents