Avatar
class Escaper { func take(_ f: @escaping () -> Void) {} } class Cat { var a: Optional<(() -> Void) -> Int> func f(escaper: Escaper) { a = { (handler: () -> Void) -> Int in escaper.take(handler) return 0 } } }
7:13 AM
Playground execution failed: error: TempGround.playground:4:26: error: passing non-escaping parameter 'handler' to function expecting an @escaping closure escaper.take(handler) ^ TempGround.playground:3:16: note: parameter 'handler' is implicitly non-escaping a = { (handler: () -> Void) -> Int in ^ @escaping
7:14 AM
プロパティで持ってる関数の型には @escaping がつけられないけど、それが、関数の引数になってる関数にも適用されるせいで、 関数からうけた関数をescapeすることができない・・・?