From: "David A. Black" Date: 2007-03-14T23:28:44+09:00 Subject: Re: A simple question regarding ruby method argument Hi -- On 3/14/07, Shin guey Wong wrote: > Hi, > > I am new to ruby and am learning it now. Can anyone point me how to pass > argument to method by reference? I mean that the methods/function able > to change the value of the argument. I am running windows using win32ole > and 1 of the method need to pass in an argument and the argument will > modify by the win32ole methods. But I don't know how to pass argument by > reference. You're (almost) always passing references around anyway. Ruby doesn't have references to references; all references are exactly one degree away from the object to which they refer. When you do this: def amend(s) s << " there." end str = "Hi" amend(str) you've changed the original string object: puts str # Hi there. because str holds a reference to that object, and s in the method is a copy of str (i.e., a copy of the reference, not the string). David -- Q. What is THE Ruby book for Rails developers? A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) (See what readers are saying! http://www.rubypal.com/r4rrevs.pdf) Q. Where can I get Ruby/Rails on-site training, consulting, coaching? A. Ruby Power and Light, LLC (http://www.rubypal.com)