Closures and type aliases
suggest changeA closure type can be named with a typealias. That is convenient when the same signature is used in several places, such as network callbacks or user-interface event handlers.
typealias ClosureType = (Int, Int) -> Int
You can then use that name in a function:
func apply(_ x: Int, _ y: Int, operation: ClosureType) -> Int {
return operation(x, y)
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents