From: Csaba Henk Date: 2004-08-06T06:36:27+09:00 Subject: Sets are not extensional (FYI: the phenomena described in the sequel were seen produced by the following ruby instances: a vanilla 1.8.1, a Debianish 1.8.2 and a cvs snapshot from the 10th of May, identifying itself as 1.9.0.) require 'set' #the empty set: Set[] => # #the singleton of the empty set: Set[ [Set[]] ] => #]}> #if sets were extensional as God ordered, this would give the same, but... Set[ [Set[], Set[]] ] => #, #]}> #and also... Set[Set[]].member? Set[] => false [Set[], Set[]].uniq => [#, #] Set[ [Set[]] ] - Set[ [Set[]] ] => #]}> #anyway... Set[] == Set[] => true Set[ [Set[]] ] == Set[ [Set[]] ] => false (Set.new behaves the same way as Set[]) Now I don't see what's the purpose of having a set class which is not extensional (ie., two sets behave as the same one in all respect if their elements are the same). But, given it's non-extensional, why isn't it consequently non-extensional ("Set[] == Set[]" evaluates in an extensional manner, that is, to "true")? And how does Array#uniq work? -- by what rule does it dispose elements if not by getting "true" by a "==" comparison with an other member of the array? -- Csaba "There's more to life, than books, you know but not much more..." [The Smiths] *** If you want to send me a mail, see it in the mailto link at http://www.renyi.hu/~ekho/egyelore.html