Skip to content

Commit e885ea7

Browse files
committed
SE-0220 count(where:)
1 parent 003a685 commit e885ea7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Source/Sequence_Extensions.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ public extension ISequence /*: ICustomDebugStringConvertible*/ { // 74092: Silve
8585
return self.Where() { return try! includeElement($0) }
8686
}
8787

88+
public func count(`where` countElement: (T) throws -> Bool) rethrows -> Int {
89+
var result = 0;
90+
for i in self {
91+
if try countElement(i) {
92+
result++
93+
}
94+
}
95+
return result
96+
}
97+
8898
public var first: T? {
8999
return self.FirstOrDefault()
90100
}

0 commit comments

Comments
 (0)