<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><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></body></html>