hash - Why does Ruby hashes use eql? and not == -
i see many notions of equality in ruby.
== eql? === equal?
and of them have different semantics. me there ought 2 of them, 1 reference equality , other value equality. don't see why ruby needed eql?
, ===
.
i found this question says distinction value , value , type.
specifically, don't understand why hash
need check type (which test in ==
method itself)
hash
requires keys must support eql?
because needs hash code internally.
for example, 1 == 1.0
true, while 1.eql? 1.0
false. 1
, 1.0
have different hash codes, can't treated equivalent keys in hash
.
Comments
Post a Comment