Avatar
Optional Chaining が Optional を flatten することが引き起こすちょっと微妙な(おもしろい?)例。 @swift-4.2.4 func foo(_ x: [Int?]?) -> Any { return x?[0] as Any } func bar<T>(_ x: [T]?) -> Any { return x?[0] as Any } let a: [Int?]? = [2, 3, 5] print(String(describing: foo(a))) print(String(describing: bar(a))) (edited)
👀 1