I prefer single quotes over double quotes because you might be able to
confuse a double quote with two single quotes. Not really an issue,
but just a preference.

I generally choose my strings like so:

Formatting a data model => ERB
Multi line string => Heredoc
Single line string with interpolation => Double quotes
Single line string containing quotes => %q{...}
Anything else => Single quotes

On Wed, Mar 11, 2009 at 2: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