From: Mathieu Bouchard Date: 2001-01-19T06:52:30+09:00 Subject: [ruby-talk:9525] Re: Newbie question: call-by-reference > |Hello there, I�m just stuck on this. I�ve been searching the mailing > |list and found nothing, so it must be too obvious. > |But indeed, how could I get in a method call a reference to the argument > |--instead of the value--so I can modify it inside. > How about wrapping the value by an array? > def incr(i) > i[0]+=1 > end > a = [0] > incr(a) > Little bit ugly, but call by reference is conceptually ugly I > believe. ;-) Zero-Dimensional Arrays. Fun For The Whole Family. class Variable def initialize(value=nil) @value = value end def [](); @value; end def []=(value); @value = value; end end matju