Search code examples
rubystringquotation-marks

Difference between double quotes and single quotes in Ruby


What is the difference between double quotation marks "" and single quotation marks '' in Ruby?

As far as I have seen this seems to only be a choice of preference and there is no change in function unless the two are accidentally mixed, ie "Some String'.


Solution

  • Double-quotes interpolates.

    Single-quotes do not, e.g.,

    puts "Hi #{42+5}"
    => "Hi 47"
    
    puts 'Hi #{42+5}'
    => "Hi #{42+5}"