Strange bahaviour of "Set"

T

Timo Hoepfner

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top