Assumption: In most cases, it doesn't make a big difference.
Only double quotes can be expanded = Cannot be done with single quotes
'#{foo} bar' ⇨ "#{foo} bar"
So is there a case where single quotes are used?
There is a conclusion.
In particular, Single quotes are useful when you want to keep the characters you type "as is" without escaping them. For example, the "backslash" character is treated as a special character on many systems, like the newline character \ n. If you enclose the string in single quotes, you can easily include special characters such as the backslash character in the variable as they are.
'\ n'#'Backslash n'is treated as is => "\n"
Recommended Posts