S
Stephen Bannasch
I'm using set in the ruby standard library to produce collections of
unique objects from enumerable objects with duplicates but it's
doesn't appear to work with hash objects.
$ ruby --version
ruby 1.8.5 (2006-12-25 patchlevel 12) [i686-darwin8.9.1]
$ irb
irb(main):001:0> require 'set'
=> true
irb(main):002:0> a = [1,1,2,3]
=> [1, 1, 2, 3]
irb(main):003:0> b = [{:a1 => "123"}, {:a1 => "123"}, {:b1 => "123"}]
=> [{:a1=>"123"}, {:a1=>"123"}, {:b1=>"123"}]
irb(main):004:0> seta = a.to_set
=> #<Set: {1, 2, 3}>
irb(main):005:0> setb = b.to_set
=> #<Set: {{:a1=>"123"}, {:a1=>"123"}, {:b1=>"123"}}>
irb(main):006:0> b[0] == b[1]
=> true
Am I doing something wrong?
unique objects from enumerable objects with duplicates but it's
doesn't appear to work with hash objects.
$ ruby --version
ruby 1.8.5 (2006-12-25 patchlevel 12) [i686-darwin8.9.1]
$ irb
irb(main):001:0> require 'set'
=> true
irb(main):002:0> a = [1,1,2,3]
=> [1, 1, 2, 3]
irb(main):003:0> b = [{:a1 => "123"}, {:a1 => "123"}, {:b1 => "123"}]
=> [{:a1=>"123"}, {:a1=>"123"}, {:b1=>"123"}]
irb(main):004:0> seta = a.to_set
=> #<Set: {1, 2, 3}>
irb(main):005:0> setb = b.to_set
=> #<Set: {{:a1=>"123"}, {:a1=>"123"}, {:b1=>"123"}}>
irb(main):006:0> b[0] == b[1]
=> true
Am I doing something wrong?