I usually follow the following rule:
never use double quotes (or %Q
or %W
) unless you interpolate
The reason for this is that if you are trying to track down a security or security error, you immediately know when you look at the beginning of a line that there can be no code inside it, so there can be no error.
However, I also follow the following exception to the rule:
use double quotes if they make the code more readable
those. I prefer
"It time"
above
'It\ time' %q{It time}
Technically, single quotes are infinitely faster to process than double quotes, but that doesn’t matter because
- the program is processed only once, during startup there is no difference in execution performance
- the difference in performance is very small.
- the time spent parsing the strings doesn't matter compared to the time spent syntaxing the Ruby crazier syntax.
So, the answer to your question: Yes, there is an advantage, namely that you will immediately notice if the line can contain code.
source share