Last active
June 9, 2018 21:41
-
-
Save vhart/88f711319ca0df33a9461cdfa6f4bc19 to your computer and use it in GitHub Desktop.
Filter2
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
struct Filter<Object> { | |
let keyPath: PartialKeyPath<Object> | |
let matcher: (Any) -> Bool | |
init<Type>(keyPath: KeyPath<Object, Type>, matcher: @escaping (Type) -> Bool) { | |
self.keyPath = keyPath | |
self.matcher = { value in | |
guard let typedValue = value as? Type else { return false } | |
return matcher(typedValue) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment