File tree Expand file tree Collapse file tree 1 file changed +13
-14
lines changed Expand file tree Collapse file tree 1 file changed +13
-14
lines changed Original file line number Diff line number Diff line change @@ -308,44 +308,43 @@ end
308308Use 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
318312user = {
319313 :login => " defunkt" ,
320314 :name => " Chris Wanstrath"
321315}
322316
317+ # good
318+ user = {
319+ login: " defunkt" ,
320+ name: " Chris Wanstrath"
321+ }
323322```
324323
325324Use 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
333328user = User .create(:login => " jane" )
334329link_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
337336If 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
341340hsh = {
342- : user_id => 55 ,
341+ user_id: 55 ,
343342 " followers-count" => 1000
344343}
345344
346- # bad
345+ # good
347346hsh = {
348- user_id: 55 ,
347+ :user_id => 55 ,
349348 " followers-count" => 1000
350349}
351350```
You can’t perform that action at this time.
0 commit comments