Reputation: 28141
There is a string:
str = "foo\nbar"
How can I escape it to:
'foo\nbar'
?
I noticed "#{str}"
doesn't work.
Upvotes: 2
Views: 1322
Reputation: 97004
Add another \
:
"foo\\nbar" == 'foo\nbar' #=> true
Single-quoted strings do not have interpolation, so #{str}
does nothing special in them.
Upvotes: 2