Skip to content
This repository has been archived by the owner on May 10, 2019. It is now read-only.

Commit

Permalink
Merge pull request #5 from alphagov/permissive-quotes
Browse files Browse the repository at this point in the history
Suggest a more permissive use of string quoting.
  • Loading branch information
dhwthompson committed Feb 14, 2013
2 parents ea25574 + 24ba183 commit 5a7a5e3
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions ruby.md
Original file line number Diff line number Diff line change
Expand Up @@ -603,18 +603,10 @@
email_with_name = "#{user.name} <#{user.email}>"
```
- Use double-quoted strings. Most files will need some double-quoted strings,
so it’s more consistent. Interpolation is in any case easy to see thanks
to syntax highlighting, and there is no speed advantage to using single
quotes.
```ruby
# bad
name = 'Bozhidar'
# good
name = "Bozhidar"
```
- Try not to mix up single-quoted and double-quoted strings within a file:
it can make the code harder to read. *Definitely* don't mix up single-quoted
and double-quoted strings within a method. If in doubt, use double-quoted
strings, because you’ll probably need to use interpolation somewhere.

- Avoid using `String#+` when you need to construct large data chunks.
Instead, use `String#<<`. Concatenation mutates the string instance
Expand Down

0 comments on commit 5a7a5e3

Please sign in to comment.