> On May 6, 2016, at 3:15 PM, Joe Groff via swift-evolution > <[email protected]> wrote: > >> On May 6, 2016, at 12:21 PM, Jacob Bandes-Storch via swift-evolution >> <[email protected] <mailto:[email protected]>> wrote: >> >> Does this affect the ability to use "x as? Int" (and similar) when x is an >> NSNumber? > > No, this only affects compile-time implicit conversions. I proposed changing > the runtime behavior of dynamic casts in SE-0083: > > https://github.com/apple/swift-evolution/blob/master/proposals/0083-remove-bridging-from-dynamic-casts.md > > <https://github.com/apple/swift-evolution/blob/master/proposals/0083-remove-bridging-from-dynamic-casts.md> I’d just like to throw in that the ability to use “x as? Int” when x is an NSNumber is terrible.
let num: AnyObject = NSNumber(int: 5) let int = num as? Int // 5 let float = num as? Float // 5 let int32 = num as? Int32 // nil! Completely unexpected failure, and you’ll never know about it until runtime. Charles
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
