From: Reimer Behrends Date: 2004-08-08T01:51:22+09:00 Subject: Re: Sets are not extensional Csaba Henk (csaba@phony_for_avoiding_spam.org) wrote: [...] > "Set" can be forced to behave extensionally by doing so: > > class Set > def eql? other > subset? other and other.subset? self > end > def hash > to_a.hash > end > end Note that to_a.hash is effectively non-deterministic. If @hash == { 1 => true, 2 => true }, then to_a can be both [1, 2] and [2, 1], with different hash values. To generate a correct hash function, you have to use something like: to_a.map{|el| el.hash}.sort.hash or: to_a.inject(0){|a,b| a ^ b.hash} Reimer Behrends