From: Geert Fannes Date: 2006-03-14T17:32:13+09:00 Subject: Re: how to introduce reference objects into ruby In Ruby, there's the []= and [] operators which you can define together. The []= can play both the role of subscripting and assignment without needing any intermediate references. Also, Ruby's subscript operator can take any number of arguments. The right-handed value is always the last in the list of args. class MyMatrix ... def []=(i,j,value) @rows[i][j]=value @columns[i][j]=value end end mm=MyMatrix.new mm[3,5] = 42 Indeed, the only drawback is that I have to keep the row and column-wise elements synchronized, e.g., after an addition or something. For a matrix with equal row and column sizes, this would mean a duplication of the needed operations if a reference object existed. But when row "i" is much longer than column "j", I would rather only lookup and modify the element (i,j) via the columns, since the Hash llokup for the row will take much longer. Greetings, Geert.