Skip to content

Instantly share code, notes, and snippets.

@omochi
Created April 12, 2018 04:03
Show Gist options
  • Save omochi/b9395558f4c68ed11a56b01ab8de1a89 to your computer and use it in GitHub Desktop.
Save omochi/b9395558f4c68ed11a56b01ab8de1a89 to your computer and use it in GitHub Desktop.
extension Array {
public mutating func remove(where: (Element) -> Bool) {
while let index = self.index(where: `where`) {
remove(at: index)
}
}
public func removed(where: (Element) -> Bool) -> [Element] {
var copy = self
copy.remove(where: `where`)
return copy
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment