extension Array {
func removeObject(object: T) {
var index = find(self, object)
self.removeAtIndex(index)
}
}
>
Implementation in Swift 2:
extension Array {
mutating func removeObject(object: T) -> Bool {
var index: Int?
for (idx, objectToCompare) in self.enumerate() {
if let toCompare = objectToCompare as? T {
if toCompare == object {
index = idx
break
}
}
}
if(index != nil) {
self.removeAtIndex(index!)
return true
} else {
return false
}
}
}