From: Florian Gross Date: 2007-07-27T23:33:09+09:00 Subject: Re: How to pass arguments by reference in a function On Jul 27, 8:32 am, "Robert Klemme" wrote: > 2007/7/27, ashishwave : > > > if i pass arguments in a function then they get passed by value. how > > to get it passed by reference. > > You can't. There are some solutions to this depending on situation: > > 1. inplace modification of arguments (Strings, Arrays, Hashes - all > sorts of containers) > > 2. multiple return values > > 3. work with instance variables 4. passing lambdas around x, y = 1, 2 x_ref = [lambda { x }, lambda { |x| }] y_ref = [lambda { y }, lambda { |y| }] swap(x_ref, y_ref} See http://flgr.0x42.net/code/variable.rb