Skip to content

Commit 20e1ffc

Browse files
Merge pull request #83 from vitorgalvao/patch-1
STYLEGUIDE.md: consistent ordering of bad and good
2 parents 3c8722f + d3d7425 commit 20e1ffc

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

STYLEGUIDE.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -308,44 +308,43 @@ end
308308
Use the Ruby 1.9 syntax for hash literals when all the keys are symbols:
309309

310310
``` ruby
311-
# good
312-
user = {
313-
login: "defunkt",
314-
name: "Chris Wanstrath"
315-
}
316-
317311
# bad
318312
user = {
319313
:login => "defunkt",
320314
:name => "Chris Wanstrath"
321315
}
322316

317+
# good
318+
user = {
319+
login: "defunkt",
320+
name: "Chris Wanstrath"
321+
}
323322
```
324323

325324
Use the 1.9 syntax when calling a method with Hash options arguments or named arguments:
326325

327326
``` ruby
328-
# good
329-
user = User.create(login: "jane")
330-
link_to("Account", controller: "users", action: "show", id: user)
331-
332327
# bad
333328
user = User.create(:login => "jane")
334329
link_to("Account", :controller => "users", :action => "show", :id => user)
330+
331+
# good
332+
user = User.create(login: "jane")
333+
link_to("Account", controller: "users", action: "show", id: user)
335334
```
336335

337336
If you have a hash with mixed key types, use the legacy hashrocket style to avoid mixing styles within the same hash:
338337

339338
``` ruby
340-
# good
339+
# bad
341340
hsh = {
342-
:user_id => 55,
341+
user_id: 55,
343342
"followers-count" => 1000
344343
}
345344

346-
# bad
345+
# good
347346
hsh = {
348-
user_id: 55,
347+
:user_id => 55,
349348
"followers-count" => 1000
350349
}
351350
```

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy