15 lines
264 B
Swift
15 lines
264 B
Swift
import Foundation
|
|
|
|
extension Array {
|
|
|
|
func count(where closure: (Element) -> Bool) -> Int {
|
|
var result = 0
|
|
forEach { element in
|
|
if closure(element) {
|
|
result += 1
|
|
}
|
|
}
|
|
return result
|
|
}
|
|
}
|