Table of Contents

Buy me a coffeeBuy me a coffee

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"
=> nil
irb(main):> puts 'a\nb'
=> nil

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.