From: Joel Pearson Date: 2013-02-04T22:32:55+09:00 Subject: Re: Select "columns" from multidimensional array? >> class Excel_Sheet > I wouldn't do that. With the basic types it is usually much better to > use delegation (i.e. have a member of that type) than exposing the > full API via inheritance. The whole point of OO is to control > internal state which is usually quite difficult when exposing a > complete API of Array because anybody can insert and remove elements. > > Btw. the "self." in your code are superfluous. > > Kind regards > > robert Ok, I wasn't sure how to create an object which behaved like an array. I've tried this instead: class Excel_Sheet def initialize( val=[] ) val = %w(A1 A2 A3 B1 B2 B3 C1 C2 C3).each_slice(3).to_a if val == 'test' fail ArgumentError, 'Must be multidimensional array' unless val[0].class == Array || val.empty? replace val end end It seems to work ok. I didn't know how to use self at first, I think I understand it a bit better now. Thanks for the advice :) -- Posted via http://www.ruby-forum.com/.