TypealiasSwift

    Void

    The return type of functions that don’t explicitly specify a return type, that is, an empty tuple ().

    typealias Void = ()

    Overview

    When declaring a function or method, you don’t need to specify a return type if no value will be returned. However, the type of a function, method, or closure always includes a return type, which is Void if otherwise unspecified.

    Use Void or an empty tuple as the return type when declaring a closure, function, or method that doesn’t return a value.

    // No return type declared:
    func logMessage(_ s: String) {
        print("Message: \(s)")
    }
    
    let logger: (String) -> Void = logMessage
    logger("This is a void function")
    // Prints "Message: This is a void function"