Skip to content

Commit cf921bf

Browse files
author
Bozhidar Batsov
committed
[rubocop#184 rubocop#222] Acknowledge double-quoted strings as good style
1 parent 35b26de commit cf921bf

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

README.md

+26-8
Original file line numberDiff line numberDiff line change
@@ -2391,16 +2391,34 @@ hash rockets syntax.
23912391
"#{ user.last_name }, #{ user.first_name }"
23922392
```
23932393

2394-
* Prefer single-quoted strings when you don't need string interpolation or
2395-
special symbols such as `\t`, `\n`, `'`, etc.
2394+
* Adopt a consistent string literal quoting style. There are two
2395+
popular styles in the Ruby community, both of which are considered
2396+
good - single quotes by default and double quotes by default.
23962397

2397-
```Ruby
2398-
# bad
2399-
name = "Bozhidar"
2398+
* Prefer single-quoted strings when you don't need string interpolation or
2399+
special symbols such as `\t`, `\n`, `'`, etc.
24002400
2401-
# good
2402-
name = 'Bozhidar'
2403-
```
2401+
```Ruby
2402+
# bad
2403+
name = "Bozhidar"
2404+
2405+
# good
2406+
name = 'Bozhidar'
2407+
```
2408+
2409+
* Prefer double-quotes unless your string literal contains `"` or escape characters you want to suppress.
2410+
2411+
```Ruby
2412+
# bad
2413+
name = 'Bozhidar'
2414+
2415+
# good
2416+
name = "Bozhidar"
2417+
```
2418+
2419+
The second style is arguably a bit more popular in the Ruby
2420+
community. The string literals in the this guide, however, are
2421+
aligned with the first style.
24042422

24052423
* Don't use the character literal syntax `?x`. Since Ruby 1.9 it's
24062424
basically redundant - `?x` would interpreted as `'x'` (a string with

0 commit comments

Comments
 (0)