In ruby using a single quote is faster than double quotes as we can see in the message : Is there a performance gain in using single quotes vs double quotes in ruby?.
So why does everyone use double quotes (or both)???
Some examples :
- https://github.com/rails/rails/blob/master/activerecord/test/models/company.rb
- https://github.com/sinatra/sinatra/blob/master/test/routing_test.rb
- https://github.com/jnicklas/capybara/blob/master/spec/rack_test_spec.rb
(I know, it’s not everyone but the majority.)
EDIT 1 : Interpolation is not a reason!
Double quotes are not always with interpolation or anything special like this, in Sinatra :
it "defines HEAD request handlers with HEAD" do
Double quotes allows you to do interpolation :
"Number of users : #{@count_user}"Plus taking a look at the benchmarks, I’d say that at best it doesn’t matter, the overhead is very small, and some benchmarks are actually faster with double quotes …