# What is the difference between single and double quotes in Ruby strings?

Source: https://poignantguide.net/answers/read/what-is-the-difference-between-single-and-double-quotes-in-ruby/
Site: Poignant Guide Ruby Q&A, category Ruby syntax and basics
Published: 2026-11-28. Updated: 2026-11-29. Replies: 2.

## Question by Hugo D., 2026-11-28

Sorry if this is a silly one. I am on attempt number 4 of chapter 3 and I keep mixing up the quote marks. I used to set type for a living, so I like tidy punctuation, and I do not understand why Ruby has two kinds.

I tried this in a file called `quotes.rb`:

```ruby
name = 'Hugo'
puts 'Hello, #{name}'
puts "Hello, #{name}"
puts 'Line one\nLine two'
puts "Line one\nLine two"
```

And this is what I got:

```
Hello, #{name}
Hello, Hugo
Line one\nLine two
Line one
Line two
```

So the single quotes printed my code instead of my name, and the `\n` did not break the line. Attempt 1 I thought I had a typo, attempt 2 I retyped the file, attempt 3 I changed `#` to `@` (that was a bad idea). I am on Ruby 3.3 on Windows. Which one should I use, and when does it matter?

## Reply 1 by Sunita R., 2026-11-29

In Python both quote styles are identical, so this surprised me too. In Ruby the quote style decides what Ruby does with the contents. If I want a variable inside a string I use double quotes, like an f-string without the `f`.

## Reply 2 by Wes O., 2026-11-29

Dry observation from the COBOL years: a delimiter that changes the meaning of the contents is a feature, until it is a bug. Practical bit for you, Hugo: a single-quoted string can hold double quotes without any escaping. `'She said "hi"'` is fine, and `"It's fine"` is fine as well.

---
Cite as: Poignant Guide Ruby Q&A, "What is the difference between single and double quotes in Ruby strings?", https://poignantguide.net/answers/read/what-is-the-difference-between-single-and-double-quotes-in-ruby/, accessed 2026-11-29.
