[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Strange bahaviour of "Set"

Timo Hoepfner

12/12/2005 8:08:00 AM

Hi,

I already mentioned this in another thread, but I think this is of
general interest. So sorry, if you read it twice.

While working on something involving the "Set" class of the Ruby
standard library, I came across the following:

require "set"
require "test/unit"

class TestSet < Test::Unit::TestCase

def test_set
array_of_arrays=[["a", "b"]]
array_of_sets=array_of_arrays.map{|an_array| an_array.to_set}
set_of_sets=array_of_sets.to_set
contained_array=["a","b"]
contained_set=contained_array.to_set
# OK
assert_equal(true, array_of_arrays.include?(contained_array))
# OK
assert_equal(true, array_of_sets.include?(contained_set))
# fails
assert_equal(true, set_of_sets.include?(contained_set))
end
end

The third assertion fails. Is this intended behaviour?

Timo