Closed liveh2o closed 5 years ago
Protobuf::Enum delegates methods to Fixnum, which has a custom hash equality method (eql?). This causes enum values to be equivalent when using ==, ===, equals?, but not eql?**:
eql?
==
===
equals?
2.3.7 :002 > Test::EnumTestType::ZERO.eql?(::Test::EnumTestType::ZERO) => false
However, they are equilvalent to their tag value:
2.3.7 :002 > Test::EnumTestType::ZERO.eql?(::Test::EnumTestType::ZERO.tag) => true
Use the hash equality implementation from Object#eql?, which is equivalent to == instead.
Object#eql?
**The implementation changed in Ruby 2.5, so this only affects Ruby versions less than v2.5.
Released as 3.8.5.pre0 for testing purposes.
3.8.5.pre0
Released in v3.8.5.
Protobuf::Enum delegates methods to Fixnum, which has a custom hash equality method (
eql?
). This causes enum values to be equivalent when using==
,===
,equals?
, but noteql?
**:However, they are equilvalent to their tag value:
Use the hash equality implementation from
Object#eql?
, which is equivalent to==
instead.**The implementation changed in Ruby 2.5, so this only affects Ruby versions less than v2.5.