Skip to content

Instantly share code, notes, and snippets.

@nanoxd
Last active December 10, 2018 12:20
Show Gist options
  • Save nanoxd/f3d11890c264a192914a8e7034b315d1 to your computer and use it in GitHub Desktop.
Save nanoxd/f3d11890c264a192914a8e7034b315d1 to your computer and use it in GitHub Desktop.
Key Path for Closures
prefix operator ^
prefix func ^<Root, Value>(keyPath: KeyPath<Root, Value>) -> (Root) -> Value {
return { $0[keyPath: keyPath] }
}
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