> On Mar 29, 2017, at 7:05 PM, Joe Groff <jgr...@apple.com> wrote: > > KeyPath objects themselves have properties, so key1 could be a member of > KeyPath. This doesn't seem workable.
Yeah, someone pointed that out to me privately. One solution would be to make it so that an uninterrupted chain of property and subscript references is treated as constructing a key path, but parenthesizing ends the key path construction and accesses its properties instead: #keyPath(Person).friends[0].name // Key path to the `name` property of a `Person` (#keyPath(Person).friends[0]).name // Value of the `name` property of a `WritableKeyPath<Person, Person>` Optional chaining behaves the same way, and in practice it seems to work fine. In practice, I'm not sure this would come up very often, because I don't think you're likely to construct a key path and immediately start calling properties on it. But it is a concern. -- Brent Royal-Gordon Architechies
_______________________________________________ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution