ぜのぜ

しりとりしようぜのぜのぜのぜ

100日目

日記

ぬるっと100日目に到達したけど特になにもない.頑張ってやらなかったから続いているので.

今日書いたコード

let external: (() -> Void) -> Void = { _ in () }
func takesTwoFunctions(first: (() -> Void) -> Void, second: (() -> Void) -> Void) {
//    first { first {} }       // Error
//    second { second {}  }    // Error
//
//    first { second {} }      // Error
//    second { first {} }      // Error

    first { external {} }    // OK
    external { first {} }    // OK
}

takesTwoFunctions(first: { _ in }, second: { _ in })

感想

これがなぜそう言えるのか理解できていないけどまあいいか.

A parameter that’s a nonescaping function can’t be passed as an argument to another nonescaping function parameter. This restriction helps Swift perform more of its checks for conflicting access to memory at compile time instead of at runtime. https://docs.swift.org/swift-book/ReferenceManual/Types.html