Double quotes process string interpolation and escape sequences, while single quotes keep almost every character exactly as written.
In a double-quoted string, #{name} runs the code inside the braces and inserts the result. Escapes such as \n for a newline and \t for a tab turn into those characters.
In a single-quoted string, #{name} and \n stay as plain text. The only escapes are \' for a quote and \\ for a backslash.
Both forms build the same kind of String object. Use double quotes when the string needs a value or a special character inside it, and single quotes for fixed text.
name = "Alice"
puts "Hello #{name}" # Hello Alice
puts 'Hello #{name}' # Hello #{name}
puts "Line\nBreak" # Line with actual break
puts 'Line\nBreak' # Line\nBreak literally
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
The diagram below the answer is the concept . Jump to it ↓