Double Versus Single Quotes In Ruby

Difference between

  • Published: August 9, 2016

Strings in Ruby are specified with double quotes "a string" or single quotes'another string'. The main difference is that double quotes allows:

  • string interpolation:
name = 'John'
"Hello #{name}"
  • escape sequence :

irb(main):> puts "a\nb"
a
b
=> nil
irb(main):> puts 'a\nb'
a\nb
=> nil

Uruguay
Marcelo Canina
I'm Marcelo Canina, a developer from Uruguay. I build websites and web-based applications from the ground up and share what I learn here.
comments powered by Disqus
Except as otherwise noted, the content of this page is licensed under CC BY-NC-ND 4.0 ·