[ruby-core:77964] [Ruby trunk Feature#12210] Add IdentitySet class that compares members by identity
From:
knu@...
Date:
2016-11-05 09:19:21 UTC
List:
ruby-core #77964
Issue #12210 has been updated by Akinori MUSHA.
Tracker changed from Misc to Feature
I'd rather add Set#compare_by_identity.
----------------------------------------
Feature #12210: Add IdentitySet class that compares members by identity
https://bugs.ruby-lang.org/issues/12210#change-61294
* Author: Tim Perkins
* Status: Assigned
* Priority: Normal
* Assignee: Akinori MUSHA
----------------------------------------
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):
~~~ruby
a_str = "a"
s = IdentitySet.new([a_str, a_str, "b", "b"])
p s # => #<IdentitySet: {"a", "b", "b"}>
~~~
---Files--------------------------------
identity_set.diff (1.18 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>