Closures and type aliases

suggest change

A 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)
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents