From: Phlip Date: 2007-07-27T20:35:08+09:00 Subject: Re: How to pass arguments by reference in a function ashishwave wrote: > if i pass arguments in a function then they get passed by value. Ruby supports two kinds of variables; IIRC numbers, characters, booleans, and nil are "immediate", and everything else is a reference to an object. The best way to explain this is to look at Ruby's source. A VALUE is the union of a long and a pointer. Anything small enough to fit in a long is an immediate value, and everything else uses the pointer to point to a non-immediate object. So at function call time, Ruby passes the _VALUE_ by value. So immediates get copied, and objects get passed by reference. So, in addition to your other answer, you could also put your referend into a class, and pass this around. That might fit the ideals of Object Oriented Programming better than passing immediates would. -- Phlip http://www.oreilly.com/catalog/9780596510657/ ^ assert_xpath http://tinyurl.com/23tlu5 <-- assert_raise_message