Strings & Interpolation

Single quotes vs. double quotes

Ruby has two string literal forms, and unlike Python, they're not interchangeable. Single quotes ('...') are literal β€” almost nothing inside them is special. Double quotes ("...") turn on interpolation and escape sequences like \n:

puts 'Hello #{name}'   # prints literally: Hello #{name}
puts "Hello \n world"  # prints an actual newline

Rule of thumb: reach for double quotes whenever you need interpolation or an escape sequence, single quotes for plain text. Both are String β€” this is about behavior, not type.