Good question Tomasz and furthermore…
irb(main):006:0> h=Hash.new{|h,k|h[k]=1}
=> {}
irb(main):007:0> g=Hash.new{|h,k|h[k]=2}
=> {}
irb(main):008:0> h==g
=> true
irb(main):009:0> h[1] ### We just must not forget that this is an
assignment!!!
=> 1
irb(main):010:0> h==g
=> false
The second result of the comparision is clear h== {1 =>1} and g=={}
although this might be surprising I think it is about ok, without this
we could not compare to literals…
tough call though
I am eager to hear other opinions.
Robert
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.