Below you can read a part of my message to John, where I was testing the 
toolchain.

If that design for the trailing spaces is indented then I disagree with that 
design choice.

In a normal string literal it’s crystal clear that it contains multiple space 
characters at the end, because it’s visible to the reader of that code. As 
shown below, if Xcode wouldn’t help here, the end result might contain spaces 
which could be caused by an accident and are not clear to the reader at all.

I suggest to align this behavior with normal string literals by stripping all 
space characters at the end of each line, just like Xcode does, unless they are 
explicitly annotated by a backslash, which would be clear to the reader of the 
code.

That said, this:

let s0 = "abc\n"

let s1 = """↵
    abc···↵
    """
     
let s2 = """↵
    abc···\↵
    """
     
let s3 = """↵
    abc···\n\↵
    """
     
s0 == s1         // => true
s0 == s2         // => false
s2 == "abc···"   // => true
s3 == "abc···\n" // => true
Xcode does trip trailing spaces by default for me, however I was able to press 
spacebar a couple times and these spaces where not trimmed by the current 
toolchain.

“”"↵
AA····↵
“”"

The string was equivalent to “\nAA····\n”




The strange character is actually a white space displayed by Xcode.

-- 
Adrian Zubarev
Sent with Airmail

Am 12. April 2017 um 22:06:01, Adrian Zubarev (adrian.zuba...@devandartist.com) 
schrieb:

Exactly, I feel like we found a Swifty version of a multi-line string literal. 
:)



-- 
Adrian Zubarev
Sent with Airmail

Am 12. April 2017 um 21:58:37, Vladimir.S via swift-evolution 
(swift-evolution@swift.org) schrieb:

this:
"""
one
two
"""
should be just the same as "one\ntwo\n"

If one wants some advanced tuning of line ends, he/she can use a backslash, for 
example
"""
one
two\
"""
should produce "one\ntwo"
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to