Skip to content

Instantly share code, notes, and snippets.

@pofat
Created May 22, 2022 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pofat/8f81097c01e7791bc3fb69f4171a3e42 to your computer and use it in GitHub Desktop.
Save pofat/8f81097c01e7791bc3fb69f4171a3e42 to your computer and use it in GitHub Desktop.
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