[swift-users] Flatmap initializer inconsistency
Zhao Xin
owenzx at gmail.com
Mon May 1 14:11:27 CDT 2017
In my test, compiler thought you use `init?(exactly value: Double)`, which
returns nil. So this is not a bug.
Zhaoxin
On Tue, May 2, 2017 at 1:39 AM, Halen Wooten via swift-users <
swift-users at swift.org> wrote:
> Hi,
>
> I'm seeing a weird issue with using an initializer in flatMap. Here's
> an example:
>
> ```
> let time: TimeInterval? = 662.82582598600004
> let intTimeFlatmap = time.flatMap(Int.init) // nil
> let intTime = Int(time!) // 662
> ```
>
> I would expect for the flatMap call to return an optional Int with the
> proper value of 662. Is there something I'm misunderstanding, or is
> this a swift bug?
>
> Thanks,
> Halen
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170502/97637c16/attachment.html>
More information about the swift-users
mailing list