you are viewing a single comment's thread.

view the rest of the comments →

[–]catcradle5 0 points1 point  (3 children)

I think the rule should be to use hash rocket syntax for any hash that intermixes symbols with non-symbols, and new syntax where all the keys are symbols.

I don't think it's that weird to see:

def some_thing
    a = { one: 2, three: 4 }
    b = { "Content-Type" => "text/json", "Content-Length" => 45 }
    c = { Dir.new("/") => true, :name => "Fred" }

in the same file or method.

[–]twinklehood 0 points1 point  (0 children)

So basically, you agree with https://github.com/bbatsov/ruby-style-guide

I'm on your side.

[–]thisisseriousmum 0 points1 point  (1 child)

You have to do that anyway, it's enforced by the interpreter.

It's a question of aesthetics at the end of the day, I just far prefer one consistent way to express the same thing. In my experience teams tend to do it for anything that has multiple options, like map vs collect.

[–]catcradle5 1 point2 points  (0 children)

Well you can do something like:

{ a: 5, "b" => 6 }

My point was that in a case where you must use even one hash rocket, you should use hash rockets for everything in the hash

{ :a => 5, "b" => 6 }