File tree 1 file changed +26
-8
lines changed
1 file changed +26
-8
lines changed Original file line number Diff line number Diff line change @@ -2391,16 +2391,34 @@ hash rockets syntax.
2391
2391
"#{ user.last_name } , #{ user.first_name } "
2392
2392
` ` `
2393
2393
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.
2396
2397
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.
2400
2400
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.
2404
2422
2405
2423
* Don ' t use the character literal syntax `?x`. Since Ruby 1.9 it' s
2406
2424
basically redundant - ` ?x` would interpreted as ` 'x'` (a string with
You can’t perform that action at this time.
0 commit comments