As already mentioned I revised my opinion about the last content line, because 
the model I summarized mimics perfectly how you’d write text paragraphs.

I’d say most of the time string concatenation is used to combine strings on the 
same line. A string literal however should only represent the content between 
the delimiters. Including an implicit new line for the last content line might 
seem consistent to other content lines from s0 to s(n - 1) (I refer to my gist 
here), but it should be consistent to the standard string literal instead.

print("""
    foo
    foo
    """)
That will only print

foo
foo
As expected (I don’t take the new line from print into account). That is the 
natural an consistent way.

If you’d need a new line at the end you’ll have natural ways of doing so, or 
you can fallback to the explicit \n character.

print("""
    foo
    foo\n
    """)
     
// Equivalent to the print above this comment, because the backslash
// in the last line only serves precision, but has no effect on the  
// implicit new line character, because the last line doesn't add any.
print("""
    foo
    foo\n\
    """)

// Natural text way
print("""
    foo
    foo
     
    """)


-- 
Adrian Zubarev
Sent with Airmail

Am 13. April 2017 um 14:35:59, Ricardo Parada (rpar...@mac.com) schrieb:

Trailing newline 

We need consensus on whether the trailing newline on the last line should be 
included.  You are proposing it should not be included which will add an empty 
line to Brent's xml concatenation example. The example looks better when the 
trailing newline is included. 

In the more rare case where the newline is not desired on the last line then 
you can just include the backslash at the end. See Brent's revised proposal: 
https://github.com/johnno1962a/swift-evolution/blob/master/proposals/0168-multi-line-string-literals.md
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to