Table of Contents

Difference between using double quotes and single quotes in ruby

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.