Created
May 22, 2022 16:21
-
-
Save pofat/8f81097c01e7791bc3fb69f4171a3e42 to your computer and use it in GitHub Desktop.
Filter with KeyPath
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 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