I don't think NSNumber is OK here. As t1 is a struct not a literal value. If NSNumber is OK. I think the compiler is too smart than it should be.
Also, you should aware that right side of let y works in print(), but does not work in let, which is not consistent somehow. Owen On Mon, Apr 18, 2016 at 9:49 PM, Erica Sadun <er...@ericasadun.com> wrote: > > On Apr 18, 2016, at 7:23 AM, zh ao via swift-users <swift-users@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 > >
_______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users