[swift-evolution] [Review #2] SE-0161: Smart KeyPaths: Better Key-Value Coding for Swift
Ben Rimmington
me at benrimmington.com
Thu Apr 6 11:45:39 CDT 2017
> On 6 Apr 2017, at 16:29, Ricardo Parada via swift-evolution <swift-evolution at swift.org> wrote:
>
> Another thought on the use of single quotes (an possibly the proposed escape character). Do you think the closing single quote could be made optional since key paths cannot have spaces? Or would that be confusing for beginners?
Key paths can (probably) have spaces:
Welcome to Apple Swift version 3.1 (swiftlang-802.0.48 clang-802.0.48).
1> Double.nan.isNaN
$R0: Bool = true
2> Double . nan . isNaN
$R1: Bool = true
3> Double .nan .isNaN
$R2: Bool = true
4> Double. nan. isNaN
error: extraneous whitespace after '.' is not permitted
Double. nan. isNaN
^~
> For example, these two would be equivalent:
>
> let isPuppyPredicate = 'Pet.type == .dog && 'Pet.age < 12
> let isPuppyPredicate = 'Pet.type' == .dog && 'Pet.age' < 12
>
> Or this:
>
> let isPuppyPredicate = \Pet.type == .dog && \Pet.age < 12
> let isPuppyPredicate = \Pet.type\ == .dog && \Pet.age\ < 12
>
> You would use the closing character normally when wanting to invoke a method on the key path object.
>
> Any thoughts?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170406/1f8bfa56/attachment.html>
More information about the swift-evolution
mailing list