From: Stephen Bannasch Date: 2007-09-18T10:43:38+09:00 Subject: Re: [?] problem using set with hash objects Ribert, Stefano, and Jano, thanks for the pointers. I'm now using "ara.t.howard" 's arrayfields gem to get hash like access to my data structures stored in arrays. This combines well with set. Here's an example: $ sudo gem install arrayfields $ cat a.rb require 'set' require 'arrayfields' abc = Array.struct :a, :b, :c a = abc.new [1,2,3] # => [1, 2, 3] b = abc.new [1,2,3] # => [1, 2, 3] c = abc.new [4,5,6] # => [4, 5, 6] p a[:a] # => 1 p c[:a] # => 4 p a1 = [a,b,c] # => [[1, 2, 3], [1, 2, 3], [4, 5, 6]] p b1 = a1.to_set.to_a # => [[1, 2, 3], [4, 5, 6]] p b1[0][:a] # => 1 p b1[1][:c] # => 6 $ ruby a.rb 1 4 [[1, 2, 3], [1, 2, 3], [4, 5, 6]] [[1, 2, 3], [4, 5, 6]] 1 6