Created
October 30, 2015 18:50
-
-
Save ivanlesko/e86d55d4bf6b3f4122e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From: http://stackoverflow.com/a/30724543/2526115 | |
// Adds the ability to remove a certain object based on value from an array | |
extension RangeReplaceableCollectionType where Generator.Element : Equatable { | |
// Remove first collection element that is equal to the given `object`: | |
mutating func removeObject(object : Generator.Element) { | |
if let index = self.indexOf(object) { | |
self.removeAtIndex(index) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment