<div dir="ltr"><div>Hi all!</div><div><br></div><div>Currently in Swift, checking the equality of two optional arrays is much messier than it should be:</div><div><br></div><div><div>switch (optionalArray1, optionalArray2) {</div><div>    case (.Some(let a1), .Some(let a2)) where a1 == a2: return true</div><div>    case (.None, .None): return true</div><div>    default: return false</div><div>}</div></div><div><br></div><div>This is a result of the lack of a built-in overload of == for optional arrays (and optional array slices for that matter). Overloads exist for optional equatable objects and for non-optional arrays with equatable elements, but not for optional arrays with equatable elements. The standard library currently has these overloads (among others):</div><div><br></div><div>public func ==&lt;T : Equatable&gt;(lhs: T?, rhs: T?) -&gt; Bool</div><div>public func ==&lt;Element : Equatable&gt;(lhs: ArraySlice&lt;Element&gt;, rhs: ArraySlice&lt;Element&gt;) -&gt; Bool</div><div>public func ==&lt;Element : Equatable&gt;(lhs: [Element], rhs: [Element]) -&gt; Bool</div><div><br></div><div>To correct the issue, I propose two functions be added to the standard library:</div><div><br></div><div>public func ==&lt;Element : Equatable&gt;(lhs: ArraySlice&lt;Element&gt;?, rhs: ArraySlice&lt;Element&gt;?) -&gt; Bool</div><div><div>public func ==&lt;Element : Equatable&gt;(lhs: [Element]?, rhs: [Element]?) -&gt; Bool</div></div><div><br></div><div>This change would allow optional arrays to be checked for equality just as other objects are:</div><div><br></div><div>optionalString1 == optionalString2 // Already possible</div><div>requiredArray1 == requiredArray2 // Already possible</div><div>optionalArray1 == optionalArray2 // Would be possible with these changes</div><div><br></div><div>Thanks for your consideration -</div><div>Jake Heiser</div></div>