I am attempting to create an extension method for the Array type to allow for removing an item from an array
extension Array {
func remove(item: AnyObject) {
for var i = self.count - 1; i >= 0; i-- {
if self[i] == item {
self.removeAtIndex(i)
}
}
}
}
On the test condition if self[i] == item
, I get the following error: 'T' is not convertible to 'MirrorDisposition'
I've tried many different things, which include:
- Using generics:
remove<T>(item: T)
- Using the
===
operator, which just gives the error'T' does not conform to protocol 'AnyObject'
I'm new to Swift, so this is where my knowledge runs out. Any suggestions would be greatly appreciated.