From: Harry Kakueki Date: 2009-08-19T21:52:23+09:00 Subject: Re: Named Matrix like ArrayFields > > Something like: > > x = NamedMatrix.new > x.xs = %w(a b c d) # the names of the x axis > x.ys = %w(e f g h) # the names of the y axis > > So that x[:a][:f] is the same as x[0][1] for getting and setting. Also have > some dumping mechanism to get an array of arrays or arrays of hashes or even > csv or some other 2D dump. > Maybe take a look at Struct. x = Struct.new(:a,:b,:c) y = Struct.new(:d,:e,:f) var = x.new(y.new(0,1,2),y.new(10,11,12),y.new(20,21,22)) ################# p var[:c][:e] p var[2][1] p var['c']["e"] var[2][:e] = 77 p var[:c][:e] Harry -- A Look into Japanese Ruby List in English http://www.kakueki.com/ruby/list.html