uno o dos

Jared Carroll

Now in Ruby, strings can be created using single or double quotes. The only difference is that you can interpolate variables in double quoted strings. I constantly see the following confusing code:

user.name = "name"

link_to "home", root_path

Here we’re using double quoted strings, but there’s no interpolation. As soon as I see double quotes, I think there’s going to be some interpolation. Using double quotes without interpolation is flat out wrong. The above code is more correct, and much less confusing using single quotes.

user.name = 'name'

link_to 'home', root_path

This may not seem like much, but it makes a huge difference when followed consistently.