Yes but that is a bit different.  Spaces can be used for clarity or breaking up 
a chain into multiple lines maybe.  But, the space is not really part of the 
key path.  I would expect the key path to be typed in without spaces when using 
the special syntax.


> On Apr 6, 2017, at 12:45 PM, Ben Rimmington <[email protected]> wrote:
> 
> 
>> On 6 Apr 2017, at 16:29, Ricardo Parada via swift-evolution 
>> <[email protected] <mailto:[email protected]>> 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?
> 

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to