Avatar
norio_nomura 3/8/2019 12:59 AM
Swift 5 Release Notes for Xcode 10.2 Beta 4の47326318ってSwift 4.2の変更だよね。 https://developer.apple.com/documentation/xcode_release_notes/xcode_10_2_beta_4_release_notes/swift_5_release_notes_for_xcode_10_2_beta_4 @swift-4.1.3 @swift-4.2.4 @swift-5.0.3 func forceCast<U>(_ value: Any?, to type: U.Type) -> U { return value as! U } let value: Any? = 42 print(forceCast(value, to: Any.self)) // Prints "Optional(42)" // (Prior to Swift 5, this would print "42".) print(value as! Any) // Prints "Optional(42)"