Skip to content

Commit

Permalink
🔎 First and last matching
Browse files Browse the repository at this point in the history
  • Loading branch information
benlmyers committed Mar 29, 2023
1 parent 449a8b9 commit 20e0495
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Sources/FoundationPlus/Extensions/Swift/Array.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,12 @@ public extension Array where Element: Equatable {
}
return arr
}

@inlinable func first(matching match: Element) -> Element? {
self.first(where: { $0 == match })
}

@inlinable func last(matching match: Element) -> Element? {
self.last(where: { $0 == match })
}
}

0 comments on commit 20e0495

Please sign in to comment.