<div dir="ltr">Making SomeClass conform to Equatable should fix it:<div><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="color:rgb(4,51,255)">class</span> SomeClass : <span style="color:rgb(52,149,175)">Equatable</span> {</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">    <span style="color:rgb(4,51,255)">static</span> <span style="color:rgb(4,51,255)">public</span> <span style="color:rgb(4,51,255)">func</span> ==(<span style="color:rgb(4,51,255)">_</span> lhs:<span style="color:rgb(52,149,175)">SomeClass</span>, <span style="color:rgb(4,51,255)">_</span> rhs:<span style="color:rgb(52,149,175)">SomeClass</span>) -&gt; <span style="color:rgb(52,149,175)">Bool</span> {</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">        <span style="color:rgb(4,51,255)">return</span> lhs === rhs</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">    }</p>
<p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">}</p><p style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)">/Jens</p></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jul 9, 2017 at 5:11 PM, David Baraff via swift-users <span dir="ltr">&lt;<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Given 2-tuples of type (T1, T2), you should be able to invoke the == operator if you could on both types T1 and T2, right?  i.e.<div><br></div><div>(“abc”, 3) == (“abc”, 4)<span class="m_-8266073610500043056Apple-tab-span" style="white-space:pre-wrap">        </span>// legal</div><div><br></div><div>but:</div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">class SomeClass {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">    static public func ==(_ lhs:</span><span style="font-variant-ligatures:no-common-ligatures;color:#9f35da">SomeClass</span><span style="font-variant-ligatures:no-common-ligatures">, _ rhs:</span><span style="font-variant-ligatures:no-common-ligatures;color:#9f35da">SomeClass</span><span style="font-variant-ligatures:no-common-ligatures">) -&gt; </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">Bool</span><span style="font-variant-ligatures:no-common-ligatures"> {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">        return lhs === rhs</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">    }</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">}</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">let c1 = </span><span style="font-variant-ligatures:no-common-ligatures;color:#9f35da">SomeClass</span><span style="font-variant-ligatures:no-common-ligatures">()</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">let c2 = </span><span style="font-variant-ligatures:no-common-ligatures;color:#9f35da">SomeClass</span><span style="font-variant-ligatures:no-common-ligatures">()</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">let t1 = (</span><span style="font-variant-ligatures:no-common-ligatures;color:#b4261a">&quot;abc&quot;</span><span style="font-variant-ligatures:no-common-ligatures">, </span><span style="font-variant-ligatures:no-common-ligatures;color:#0536ff">c1</span><span style="font-variant-ligatures:no-common-ligatures">)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">let t2 = (</span><span style="font-variant-ligatures:no-common-ligatures;color:#b4261a">&quot;abc&quot;</span><span style="font-variant-ligatures:no-common-ligatures">, </span><span style="font-variant-ligatures:no-common-ligatures;color:#0536ff">c2</span><span style="font-variant-ligatures:no-common-ligatures">)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(5,54,255)"><span style="font-variant-ligatures:no-common-ligatures">c1</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#9f35da">==</span><span style="font-variant-ligatures:no-common-ligatures;color:#000000"> </span><span style="font-variant-ligatures:no-common-ligatures">c2<span class="m_-8266073610500043056Apple-tab-span" style="white-space:pre-wrap">                </span>// legal</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures;color:#0536ff">t1</span><span style="font-variant-ligatures:no-common-ligatures"> == </span><span style="font-variant-ligatures:no-common-ligatures;color:#0536ff">t2<span class="m_-8266073610500043056Apple-tab-span" style="white-space:pre-wrap">                </span>// illegal</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures;color:#0536ff"><br></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></div></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;line-height:normal;min-height:13px">Why is t1 == t2 not legal given that c1 == c2 IS legal?</div><div style="margin:0px;line-height:normal;min-height:13px"><br></div><div style="margin:0px;line-height:normal;min-height:13px"><br></div></div><br>______________________________<wbr>_________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br>
<br></blockquote></div><br></div>