Last active
March 7, 2019 12:33
-
-
Save samdods/9e6dacbfc10c1794009f984d096315d5 to your computer and use it in GitHub Desktop.
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
prefix func ~<A>(_ keyPath: KeyPath<A, Bool>) -> (A) -> Bool { | |
return { $0[keyPath: keyPath] } | |
} | |
// only people with empty street in their address | |
people.filter(~\.address.street.isEmpty) | |
// the names of the people with empty street | |
people.filter(~\.address.street.isEmpty).map(~\.name) | |
// => ["Tom", "Alice", "Bob"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment