From: Austin Ziegler Date: 2007-01-28T04:50:38+09:00 Subject: Re: pass by reference? The simplest way to remember this is that variables in Ruby aren't chunks of memory. When C++ programmers say that they're passing something by reference, they are simply doing a (slightly) safer operation than passing a pointer around. They are *still* referencing the memory block, but it's type checked. In Ruby, inasmuch as variables contain anything, they contain a reference. This applies even to immediate values such as nil, true, false, integers, and symbols. It just so happens that, at least for integers, the reference (the object ID, if you will) is the same as the value, shifted left once -- at least in matzruby. The others are all fixed object IDs. Making a distinction between the passing semantics of immediate values is a mistake; it invites people to peer too deeply under the hood of Ruby. Better to clarify that integers are immediate immutable values and indicate that all variables are references and the references are passed -- by value -- to methods. Scope also enters into this, but that's been discussed clearly. -austin -- Austin Ziegler * halostatue@gmail.com * http://www.halostatue.ca/ * austin@halostatue.ca * http://www.halostatue.ca/feed/ * austin@zieglers.ca