Hi,
In message "[ruby-talk:9466] Newbie question: call-by-reference"
on 01/01/18, Marc Casaldaliga <casaldaliga / ifae.es> writes:
|Hello there, I 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. ;-)
matz.