Maybe I made a mistake when testing, but I thought I was able to convert a negative Int to a large UInt by going through NSNumber (it didn't return nil from the as? cast). On Mon, May 9, 2016 at 10:11 AM Joe Groff via swift-evolution < [email protected]> wrote:
> > > On May 7, 2016, at 1:23 PM, Zach Waldowski via swift-evolution < > [email protected]> wrote: > > > > On Fri, May 6, 2016, at 11:20 PM, Charles Srstka via swift-evolution > wrote: > >> let int = num as? Int // 5 > >> let float = num as? Float // 5 > >> let int32 = num as? Int32 // nil! > > That specific behavior with Int32 seems to be an oversight in the stdlib. > > It wasn't an oversight. At the time of Swift 1.0, bridging a type implied > bidirectional implicit conversions, and if *every* integer type were > bridgeable, it would be possible to unsafely implicitly convert between any > two integer types by hopping through NSNumber. Now that we've eliminated > these implicit conversions, we could consider bridging more types. Do you > want to start another thread to discuss that idea? > > -Joe > _______________________________________________ > swift-evolution mailing list > [email protected] > https://lists.swift.org/mailman/listinfo/swift-evolution >
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
