Skip to content

Instantly share code, notes, and snippets.

@7foots
Created April 13, 2022 07:28
Show Gist options
  • Save 7foots/dcf4ec38aae90b8c9705f141a688580a to your computer and use it in GitHub Desktop.
Save 7foots/dcf4ec38aae90b8c9705f141a688580a to your computer and use it in GitHub Desktop.
Swift Array removeFirst(where:)
import Foundation
extension Array {
mutating func removeFirst(where shouldBeRemoved: (Element) throws -> Bool) rethrows {
guard let index = try firstIndex(where: shouldBeRemoved) else {
return;
}
remove(at: index)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment