[swift-users] ?? operator question
Erica Sadun
erica at ericasadun.com
Mon Apr 18 08:49:33 CDT 2016
> On Apr 18, 2016, at 7:23 AM, zh ao via swift-users <swift-users at swift.org> wrote:
>
> I do think there is something wrong here.
>
> // Xcode 7.3.1, Swift 2.2
>
> let t1: Int? = 2 // struct Int?
> let y = t1 ?? "abcdf" // error
> let x = t1 ?? NSFont(name: "", size: 0) // x: NSObject?
>
> for x, how could it be NSObject?, as t1 is a struct?
>
> zhaoxin
My guess would be NSNumber.
Strings can bridge to NSString (struct to class), enums of ErrorType to NSError (enum to class), etc.
-- E
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160418/767b525e/attachment.html>
More information about the swift-users
mailing list