As of this writing (Swift 2.1) ordinary arrays can't be Equatable. I wanted do do something likes this:
extension Array: Equatable where Element: Equatable {
// Aaaww...no go, me so sad :'(
}
So I wrapped an array in EquatableArray instead, you can use it like this:
let stuff: EquatableArray = ["Hello", "No"]
And now I can pass it along to functions expecting an Equatable If you make it a var you can append/remove just as you would with an array:
var stuff: EquatableArray = ["Hello", "No"]
stuff.append("Yo!")
stuff.removeLast()
I'm sure Apple will fix this in a future version of Swift, but until then...
EquatableArray is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "EquatableArray"
Joakim Gyllström, [email protected]
EquatableArray is available under the MIT license. See the LICENSE file for more info.