<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Sorry about the double post.<br></div><div><br>On 05 Jan 2016, at 18:26, David Hart via swift-users <<a href="mailto:swift-users@swift.org">swift-users@swift.org</a>> wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div><span style="background-color: rgba(255, 255, 255, 0);">How is it that Swift allows code like this:</span><div class=""><span style="background-color: rgba(255, 255, 255, 0);"><br class=""></span></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);"><font class="">struct Sneaky: StringLiteralConvertible {<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>init(stringLiteral value: String) {}<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>init(extendedGraphemeClusterLiteral value: String) {}<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>init(unicodeScalarLiteral value: String) {}<br class="">}<br class=""><br class="">func ~=(sneaky: Sneaky, string: String) -> Bool {<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>return false<br class="">}<br class=""><br class="">enum NormalEnum: String {<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>case Super = "super"<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>case Mario = "mario"<br class="">}</font><br class=""><br class=""><font class="">let value = NormalEnum(rawValue: "super”) // return nil!!!!</font></span></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);"><br class=""></span></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);">It hit completely by surprise today because of of a Regex library:</span></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);"><br class=""></span></div><div class=""><font class="" style="background-color: rgba(255, 255, 255, 0);">struct Regex: StringLiteralConvertible {<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>init(stringLiteral value: String) {}<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>init(extendedGraphemeClusterLiteral value: String) {}<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>init(unicodeScalarLiteral value: String) {}</font></div><div class=""><font class="" style="background-color: rgba(255, 255, 255, 0);"><br class=""></font></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);"><font class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>//...<br class="">}<br class=""><br class="">func ~=(regex: Regex, string: String) -> Bool {<br class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>return regex.matches(string)<br class="">}</font><br class=""></span></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);"><br class=""></span></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);">If I was not already a Swift enthusiast, this behaviour would have left me completely dumbfounded.</span></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);">What can we do about it?</span></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);"><br class=""></span></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);">David.</span></div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=nE9rxSXA5G4kxsTVkgv43hXwizS3O2z60WweqomIrdjaYepUWOzNIv51wL2XM-2FDxdvrjiuVGPgedxto2v-2BbQdnDbltpA50VG2WAE0QFlFDEPgF2Mcn8TeWarxsGNVKNa2-2BPLN8F8ugolwjpaRmF8MURPvmCvIPg26UnwcO7g-2F1roz1shdQ1AxVT8ORreBcqVOAzIw2pusowpMh2ivzPq9XM0cGkK8Gs6ZLvq65nCtx0-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;">
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-users mailing list</span><br><span><a href="mailto:swift-users@swift.org">swift-users@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-users">https://lists.swift.org/mailman/listinfo/swift-users</a></span><br></div></blockquote></body></html>