[swift-evolution] Thoughts on replacing \() with $() or some other symbol
Goffredo Marocchi
panajev at gmail.com
Wed Jun 22 06:20:08 CDT 2016
> So in a way you can think of \() as being a means of escaping from the string entirely. I find this more logical than the idea which other languages encourage which is that the variable is somehow embedded inside the string, which is why I actually really like having escape do this in Swift.
I guess it is only a matter of personal preference... I do find the opposite to hold true, I like to think about the variable and its expansion so to speak in the target string.
Sent from my iPhone
> On 22 Jun 2016, at 11:19, Haravikk <swift-evolution at haravikk.me> wrote:
>
>
>> On 22 Jun 2016, at 09:39, Goffredo Marocchi via swift-evolution <swift-evolution at swift.org> wrote:
>>
>> Sorry, but can you explain why the character used to escape strings is also the best choice to do Variable value extraction/String interpolation? They are two different concepts.
>
> The following two lines are equivalent:
>
> return "Value of foo is \(foo), have a nice day!"
> return "Value of foo is " + foo + "have a nice day!" // Assuming foo is a String already
>
> So in a way you can think of \() as being a means of escaping from the string entirely. I find this more logical than the idea which other languages encourage which is that the variable is somehow embedded inside the string, which is why I actually really like having escape do this in Swift.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160622/aaae3c0c/attachment.html>
More information about the swift-evolution
mailing list