Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Filter with KeyPath
struct Foo {
var bar: Int
var overThreshold: Bool {
bar > 5
}
}
let fooArray: [Foo] = ...
let filtered = fooArray.filter(\.overThreshold)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment