On Apr 24, 2006, at 7:45 AM, James Edward Gray II wrote:
class SpreadSheet def initialize( rows ) @cells = rows end def []( x, y ) @cells[y][x] end def []=( x, y, value ) # do your cell adding here... @cells[y][x] = value end end
This would allow calls like: spreadsheet[row,col] , while I think we were talking about calls like data[row,col], which would mean implementing these methods for the actual array @cells, thus overriding the accessors of @cells. Hence my aliasing suggestion. Here data is a method of SpreadSheet instances which returns the array @cells.
James Edward Gray II
Haris