struct Bar {} struct Foo { func bar() -> Bar? { return Bar() } } extension Int { func foo() -> Foo? { return Foo() } } let x = 42 let bar: Bar? = x.foo()?.bar() // ✅ OK
struct Bar {} struct Foo { func bar() -> Bar? { return Bar() } } extension Int { func foo() throws -> Foo { return Foo() } } let x = 42 let bar: Bar? = try? x.foo().bar() // ⛔ NG
struct Bar {} struct Foo { func bar() -> Bar? { return Bar() } } extension Int { func foo() throws -> Foo { return Foo() } } let x = 42 let bar: Bar? = (try? x.foo())?.bar() // ✅ OK
(edited)