Literal strings means the ruby parser doesn't have to parse the string for
any code that might have to be executed, so it's generally a good practise
to use it unless using double quotes will end up in a more readable result.

I'm not sure of the actual speed increase of using literal strings over
non-literal, but it might be worth benchmarking :)



On Wed, Mar 11, 2009 at 4:35 PM, Mark Ratjens <[email protected]>wrote:

>
> While we're on idioms, what is the consensus on when to use single
> quotes versus double quotes for string literals? I'm in the habit of
> always using single quotes unless they don't work (e.g I've got some
> code embedded in the string).
>
> For example:
>
> copy_to_path = File.join(RAILS_ROOT, 'db/migrate')
> migration_file = File.join(copy_to_path,
> "#{Time.now.strftime('%Y%m%d%H%M%S')}_categories.rb")
>
> I notice that double quotes seem to be commonly used in any context in
> preference to single quotes.
>
> Any thoughts?
>
> regards
>
> Mark
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rails-oceania?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to