Hey everyone!

I've been working with sets and I need to use them as a key in a hash.
Unfortunately, it looks like Sets are implemented as a Hash (which makes
sense), but it looks like Set#eql? calls eql? on the underlying Hash.

This seems bad to me.  It means that I can't make two sets eql? to each
other.

Take this irb session for example:

  >> require 'set'
  => true
  >> a = Set.new([1,2])
  => #<Set: {1, 2}>
  >> b = Set.new([1,2])
  => #<Set: {1, 2}>
  >> a.eql?(b)
  => false

I understand that sets are unordered, but it still seems weird to me
that the preceding code won't work.  My workaround(?) for now is
converting the set to an array and sorting the array by hash key, and
keying on that:

  >> a.to_a.sort_by { |x| x.hash }.eql?(b.to_a.sort_by { |x| x.hash })
  => true

-- 
Aaron Patterson
http://tenderlovemaking.com/