[swift-users] ?? operator question

Jens Alfke jens at mooseyard.com
Tue Apr 19 12:40:30 CDT 2016


> On Apr 19, 2016, at 4:09 AM, Marco Feltmann via swift-users <swift-users at swift.org> wrote:
> 
> "But wait a sec, how can NSFount(name: "", size: 0) result in an NSNumber?" you may ask.
> I don't now.
> The behaviour of NSFonts +fonttWithName:size: for empty/not found font name is not defined in the documentation, so ANY result is correct.

That’s not true. The result has to be an NSFont? as declared in the class interface — it can’t be an NSNumber. This has nothing to do with whether the font is not found at runtime; we’re talking about compile-time type inference.

—Jens
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160419/c68c304d/attachment.html>


More information about the swift-users mailing list