Actions
Feature #13801
closedImplement case equality test for Set#===
Feature #13801:
Implement case equality test for Set#===
Actions
Added by davidarnold (David Arnold) about 9 years ago. Updated almost 9 years ago.
Created pull request: https://github.com/ruby/ruby/pull/1673
I expect Set to act almost like Array [...]
But why? Aside from both being collections, there is no connection. Ruby's Set isn't even implemented with an Array.
The core mathematical definition of Set is based on element membership[1]. All of the characteristic operations on sets (intersection, union, difference, etc) are derived based on element membership. When #=== has the common semantics in Ruby of membership, why should the one class, which is probably most closely tied to the notion of membership, not implement this operator?
FWIW, I would not be opposed to Array implementing #=== as a membership test either, but this is not a feature request for Array.
I don't remember but I guess I didn't define Set#=== probably because Array didn't, but I agree Set#=== could be useful and intuitive, so I've merged your PR with a slight modification (alias to save an extra method call) and a test in addition to the specs. Thanks!