arrays - Inconsistent implicit hash creation in Ruby? -


OK, so I was comparing certain things to Ruby in my own DSL. The creation of one is both of them support

  x = ["key" => "Value"]  

To know the difference between arrays and hash, I think this is illegal, but the results in Ruby

  [ ["Key" = & gt; "Value"}]  

Why is that so? And why can not you do this with such syntax?

  x = ("key" => "value")  

Special Special case for the hash created from the form?

Another special case is in the function call, consider:

  Def f (x) "OK: # {x.inspect}" end F ("af" => = "bar") = & gt; OK: {"foo" = & gt; "Bar"}  

In some contexts, Hashes can be made void (by detecting the = & gt; operator)). I think the answer is simply that it was Matz's less amazing behavior.


Comments