Swift 4 introduced KeyPaths, a literal syntax that allows developers to reference properties, in order to evaluate them at a later time. Their addition went quite under the radar, because both the language and its standard library actually lack the proper tools to really unleash their full potential.
But with the simple addition of a couple helper functions, you’ll see how your code can leverage KeyPaths to become even more concise and declarative.
Code sample:
let words = ["FooBar", "Foo", "Bar"]
words.map(^\.count) // [6, 3, 3]
words.sorted(by: their(\.count)) // ["Foo", "Bar", "FooBar"]