Unary operator key paths

I’d prefer to be able to apply unary operators to KeyPath directly when Value can use the operator.

For example, I expected to be able to filter an Array of ToDos for ones awaiting completion by just passing a negated KeyPath to its completed property:

let outstanding = todos.filter(!\.completed)

I was surprised when this didn’t work.

5 Likes