Last active
December 10, 2018 12:20
-
-
Save nanoxd/f3d11890c264a192914a8e7034b315d1 to your computer and use it in GitHub Desktop.
Key Path for Closures
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 operator ^ | |
prefix func ^<Root, Value>(keyPath: KeyPath<Root, Value>) -> (Root) -> Value { | |
return { $0[keyPath: 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
let items = ["spoon", "", "fork", "", "spatula"] | |
let kitchenItems = items.filter(^\.isEmpty) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment