> On 24. May 2017, at 04:34, Xiaodi Wu via swift-evolution
> <swift-evolution@swift.org> wrote:
>
> Yes. First, the Foundation initializer converting from NSNumber has the same
> behavior:
>
> ```
> import Foundation
> let x = Int(42.5 as NSNumber) // x == 42
> ```
As of SE-170 (which is implemented in Swift 4), the label "truncating" is also
used for conversions which loose precision:
let x = Int(42.5 as NSNumber) // // warning: 'init' is deprecated
let y = Int(truncating: 42.5 as NSNumber) // 42
let z = Int(exactly: 42.5 as NSNumber) // nil
Regards ,Martin
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution