> On Jun 22, 2016, at 4:19 AM, Haravikk via swift-evolution 
> <[email protected]> wrote:
> 
> 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.

The two have equivalent output (excluding the omission of “, “ which I assume 
was a typo), but go through different code paths. I believe the interpolation 
has more opportunities for memory optimization.

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

Reply via email to