Last active
June 30, 2020 03:09
-
-
Save krzyzanowskim/d3f2181081dda78e09d52c5b8b73f208 to your computer and use it in GitHub Desktop.
anySatisfy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public extension Collection { | |
func anySatisfy(_ predicate: (Self.Element) throws -> Bool) rethrows -> Bool { | |
try reduce(false) { | |
try predicate($1) || $0 | |
} | |
} | |
} | |
/* | |
[true, false].anySatisfy { $0 == false } // true | |
[true, true].anySatisfy { $0 == false } // false | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment