0

When used to enclose strings, I'm wondering if one is more correct or common than the other? Do any firms or coding teams insist on one way or another?

Edit:

Since you would use double quotes if you are doing string interpolation, and double quotes also works for variable assigning, eg

str = "string"

Then is it acceptable to only use " " at all times? Then that saves the programmer from having to differentiate between whether to use ' ' or " ".

Lina
  • 315
  • 3
  • 12
  • Sounds like a dupe of http://stackoverflow.com/questions/6395288/ruby-double-vs-single-quotes – orde Feb 03 '15 at 01:59

2 Answers2

2

The difference between " " and ' ' is that ' ' will write exactly what you are typing and with " " you can interpolate and use escaping characters like \n new line

0

Use double quotes if you are doing string interpolation:

aux = 'World'
"Hello #{aux}"

Use single quote otherwise

You can see Ruby Styleguide in GitHub

juancito
  • 866
  • 2
  • 9
  • 22