Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #5 from alphagov/permissive-quotes

Suggest a more permissive use of string quoting.
  • Loading branch information...
commit 5a7a5e3e7642fc6fc3178595df43beca0c4fd5b9 2 parents ea25574 + 24ba183
@fatbusinessman fatbusinessman authored
Showing with 4 additions and 12 deletions.
  1. +4 −12 ruby.md
View
16 ruby.md
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.