<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">Thanks for your explanation.</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">I still think the compiler should not be that smart, causing only itself could understanding what is going on. It will be a nightmare.</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">Owen</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 19, 2016 at 7:09 PM, Marco Feltmann via swift-users <span dir="ltr"><<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Just guessed since I try to separate Swift from Objective-C frameworks.<span class=""><br>
<br>
Am 19.04.2016 um 03:15 schrieb zh ao:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I don't think NSNumber is OK here. As t1 is a struct not a literal value.<br>
</blockquote></span>
In fact t1 in an OPTIONAL struct.<br>
That means it can point to anything from `nil` to Int Struct, NSInteger and NSNumber.<br>
AFAIR it automatically bridges to NSNumber as soon as you import Foundation or a similiar framework. Same works with String. String is a struct used in plain Swift and NSString used with Foundation.<span class=""><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
If NSNumber is OK. I think the compiler is too smart than it should be.<br>
</blockquote></span>
Indeed it is. Way to smart.<br>
It is that smart that it sometimes stands in its own way.<br>
At least when used with Objective-C. Your question outlines one of those strange side effects.<span class=""><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Also, you should aware that right side of let y works in print(), but does<br>
not work in let, which is not consistent somehow.<br>
</blockquote></span>
It is consistent.<br>
You can map an OPTIONAL integer to NSNumber (using Foundation framework) but you cannot map an OPTIONAL integer to NSString.<br>
<br>
"But wait a sec, how can NSFount(name: "", size: 0) result in an NSNumber?" you may ask.<br>
I don't now.<br>
The behaviour of NSFonts +fonttWithName:size: for empty/not found font name is not defined in the documentation, so ANY result is correct.<div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br>
</div></div></blockquote></div><br></div>