Double Versus Single Quotes In Ruby

Difference between

Published:
Last modified:

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 . Terms and Policy.

Powered by SimpleIT Hugo Theme

·