Discussed at the dev meeting.
In conclusion, @matz (Yukihiro Matsumoto) wanted to change the return value of Hash#inspect
significantly and estimate its compatibility impact:
{ :key => 42 } #=> {key: 42} # if the key is a symbol
{ :== => 42 } #=> {"==": 42} # if the key is a symbol and quotes are needed
{ "str" => 42 } #=> {"str" => 42} # otherwise (note that `=>` is surrounded by spaces)
# when keys are mixed
{ :== => 1, :key => 2, "str" => 3 } # {"==": 1, key: 2, "str" => 3}
Actually, some solutions were discussed.
Solution 1: insert a space before =>
only when needed.
{ :key => 1 } # {:key=>1}
{ :== => 1 } # {:== =>1}
{ :a! => 1 } # {:a! =>1}
Solution 2: insert spaces before and after =>
consistently
{ :key => 1 } # {:key => 1}
{ :== => 1 } # {:== => 1}
{ :a! => 1 } # {:a! => 1}
Solution 3: quote keys only when needed
{ :== => 1 } # {:"=="=>1}
{ :a! => 1 } # {:"a!"=>1}
{ :key => 1 } # {:key=>1}
Matz said he likes Solution 2. However, this has a compatibility issue. It may break some existing test assertions.
Matz had had the idea of denoting symbol keys by a colon in Hash#inspect
. And the incompatibility impacts of Solution 2 and of symbol keys by colons are expected to be about the same. Rather than introducing the incompatibilities in two steps, Matz said he wants to change it at once.