[Ruby] eql? and hash on Sets

John Barnette jbarnette at gmail.com
Sun Nov 25 19:18:48 PST 2007


On Nov 25, 2007 5:42 PM, Jim Ludwig <jsl at blarg.net> wrote:
> John Barnette wrote:
> >> Given two sets, (first - second).empty? is
> >> probably going to be the best way to test for
> >> equality.
>
> If one already knows the two sets are the same
> size, then the above is true.  Otherwise one would
> need to subtract in both directions in order to
> determine equality:
>
>   (first - second).empty? && (second - first).empty?

Sorry, thinko. Replace that - with a ^. :)


~ j.


More information about the Ruby mailing list