Actions
Feature #12210
closedAdd IdentitySet class that compares members by identity
Feature #12210:
Add IdentitySet class that compares members by identity
Description
This subclass of Set handles a use case that we ran into where we needed to track instances of objects that might compare as equal.
I was surprised that there was not a core way to do this. IdentitySet allows you to do the following (trivial example using strings):
a_str = "a"
s = IdentitySet.new([a_str, a_str, "b", "b"])
p s # => #<IdentitySet: {"a", "b", "b"}>
Files
Actions