Project

General

Profile

Actions

Feature #12210

closed

Add IdentitySet class that compares members by identity

Added by tjwp (Tim Perkins) over 8 years ago. Updated about 8 years ago.

Status:
Closed
Target version:
-
[ruby-core:74498]

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

identity_set.diff (1.18 KB) identity_set.diff patch tjwp (Tim Perkins), 03/23/2016 07:20 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0