[swift-evolution] Thoughts on replacing \() with $() or some other symbol

Haravikk swift-evolution at haravikk.me
Wed Jun 22 05:19:31 CDT 2016


> 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/cb8b6b6f/attachment.html>


More information about the swift-evolution mailing list