Escaping closures
An escaping closure is a closure that is passed to a function as an argument but is called after the the function returns.
This is typically what we need in completion handlers of asynchronous calls.
Closures are non-escaping by default so we define a closure as escaping by adding the keyword @escaping before its type in the function parameters list as follows:
func apiGetData(x: Int, y: Int, completion: @escaping (Bool) -> ()) {
if x > y {
completion(false)
} else {
completion(true)
}
}