Skip to content

Instantly share code, notes, and snippets.

@vhart
Last active June 9, 2018 21:41
Show Gist options
  • Save vhart/88f711319ca0df33a9461cdfa6f4bc19 to your computer and use it in GitHub Desktop.
Save vhart/88f711319ca0df33a9461cdfa6f4bc19 to your computer and use it in GitHub Desktop.
Filter2
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