From: Michal Suchanek Date: 2008-07-27T20:45:44+09:00 Subject: Re: weird backsplash behaviour inside single quotes On 27/07/2008, Pit Capitain wrote: > 2008/7/25 Sebastian Hungerecker : > > > Yes, but you can get that with double quotes too: > > "\#{this string is not interpolated}" > > So what's the upside of '\#{this string is not interpolated}'? Right. No > > backslash. I think, that's what Michal meant. > > > Sebastian, if you have a dial with a range from 1 to 9 and you see > someone turning it from 1 to 6, you can't say to him "you have to turn > the dial farther up to 9 because this has been your goal". > > I still think that the reason for having single quoted strings is to > have them doing less of things like string interpolation than double > quoted strings. Yes, you can do the same with double quoted strings by > adding more backslashes. But for me, minimizing the number of > backslashes (turning the dial to 9) has never been the goal of single > quoted strings. As Michal has shown, then they should behave > differently than they do now. > > This is why I have been asking him why he thought that the goal was to > minimize the number of backslashes. Because I do not see other goal the single quoted strings might possibly have. If we did not want to avoid backslashes we could use double quoted strings all the time. The problem with the current state is that the single quoted strings are not a good tool. There is no simple rule of thumb for using them. You have to repeat all the thought that went into designing them before you can understand how they work. And you are likely to find out only when they do not work the way you wanted. In contrast, double quoted strings have some special characters which most people use so they are aware of them, and if you do not want them to be special you escape them with a backslash. It's clear, works the same all the time, just way too many backslashes in some cases. Perhaps this would be for the ruby wishlist thread: better single-quoted strings ... Thanks Michal