From: Glenn Parker Date: 2005-01-04T22:24:12+09:00 Subject: Re: Method arguments Mikael Brockman wrote: > "Tookelso" writes: >> >>When you pass an argument to a method, is it passed by reference, or by >>value? > > By value. But remember that the value of a variable is always a > reference! Of all the explanations so far, I liked this one best. Thanks, Mikael! If Ruby really passed arguments by reference (like e.g. C++), then Tookelso would not be confused. In reality, Ruby passes a copy of the caller's reference. This copy must be handled rather gently, otherwise the object referenced from caller's scope quickly becomes inaccessible. It's a subtle point, and it's easy to see why people familiar with traditional call-by-reference semantics would be misled. I know I didn't fully appreciate it until now. -- Glenn Parker | glenn.parker-AT-comcast.net |