Skip to content

Commit

Permalink
Add string section with interpolation hints.
Browse files Browse the repository at this point in the history
  • Loading branch information
mitio committed Sep 18, 2011
1 parent be08fb1 commit 8a4ab51
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,21 @@ in *Ruby* now, not in *Python*.
* Don't use exceptions for flow of control.
* Avoid rescuing the `Exception` class.
## Strings
* Prefer string interpolation instead of string concatenation:
```Ruby
# bad
email_with_name = user.name + ' <' + user.email + '>'
# good
email_with_name = "#{user.name} <#{user.email}>"
```
* Prefer single-quoted strings when you don't need string interpolation or
special symbols such as `"\t"`, `"\n"`, etc.

## Misc

* Write `ruby -w` safe code.
Expand Down

0 comments on commit 8a4ab51

Please sign in to comment.