<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Could you please file a bug mentioning where the code example was taken from? <div class=""><br class=""></div><div class="">Thanks,</div><div class="">- mish</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 7, 2015, at 5:11 PM, Karl Pickett via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><font face="monospace, monospace" class="">This code example:</font><div class=""><font face="monospace, monospace" class=""><br class=""></font></div><div class=""><div class=""><font face="monospace, monospace" class="">if someInstance.dynamicType === someInstance.self {</font></div><div class=""><font face="monospace, monospace" class=""> print("The dynamic and static type of someInstance are the same")</font></div><div class=""><font face="monospace, monospace" class="">} else {</font></div><div class=""><font face="monospace, monospace" class=""> print("The dynamic and static type of someInstance are different")</font></div><div class=""><font face="monospace, monospace" class="">}</font></div><div class=""><font face="monospace, monospace" class="">// prints "The dynamic and static type of someInstance are different”</font></div><div class=""><font face="monospace, monospace" class=""><br class=""></font></div><div class=""><font face="monospace, monospace" class="">Does not compile on Linux. It also is quite confusing - comparing a type === an instance? It compiles on my mac but is it using some objc weirdness or simply a bug? </font></div></div><div class=""><font face="monospace, monospace" class=""><br class=""></font></div><div class=""><font face="monospace, monospace" class="">I think the example means to do something like this:</font></div><div class=""><font face="monospace, monospace" class=""><br class=""></font></div><div class=""><font face="monospace, monospace" class=""><div class="">// Note: === won't compile</div><div class="">if SomeBaseClass.self == someInstance.dynamicType {</div><div class=""> print("is base")</div><div class="">} else if SomeSubClass.self == someInstance.dynamicType {</div><div class=""> print("is subclass")</div><div class="">} else {</div><div class=""> print("is neither!")</div><div class="">}</div><div class=""><br class=""></div><div class="">One other minor typo:</div><div class=""><br class=""></div><div class=""><div class="">“// and the runtime type of someInstance is SomeBaseClass”</div><div class=""><br class=""></div><div class="">should be SomeSubClass.</div><div class=""><br class=""></div></div><div class=""><br class=""></div><div class=""><br class=""></div></font></div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=xTF6JWnt2pl7kNka7081D3VajDoXFZTI5JEuSuQLnconTYTagsFwyQD5yH5Q-2FkWGzsdezLQO-2BlRXoXS98iGpcQHxQ4sI7CBkaAhijyBhbdeB7aJKS0MD-2BgksZfJlN64PfPXZflNQ-2F3bdO-2BLFJCuQNE3FNMqzVkcqzG2l31SDqk6YLH72vhNIcdiNTO63jVjf-2FE33aasj44O-2BMnmLvKXVZ-2BBDuhYiiHNvg0CU-2BAwLAXU-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""></div></body></html>