4 ms·
> Edit: I do think it's stupid to make the identity-equals operator overloadable. Identity-equals and value-equals are separate concepts. In C++ this isn't an i
by msbarnett 11y ago
> Edit: I do think it's stupid to make the identity-equals operator overloadable. Identity-equals and value-equals are separate concepts. In C++ this isn't an issue because == is the value-equals operator.
In Ruby, == is value-equals at well (identity-equality being such a rarely needed concept in Ruby that it wouldn't make sense to privilege it with its own operator).
Identity equality in Ruby is provided by:
a.object_id == b.object_id
- anamexis 11y agoFor identity equality, there's also `Object#equal?`. http://ruby-doc.org/core-2.2.3/Object.html#method-i-eql-3F http://ruby-doc.org/core-2.2.3/Object.html#method-i-eql-3F