From: Christopher Dicely Date: 2010-08-28T06:03:20+09:00 Subject: Re: Parameter passing On Fri, Aug 27, 2010 at 12:42 PM, Fritz Trapper wrote: > Is it possible, to pass local variables by refrerence to method? > > I would like to do something like that: > > def meth(dest) >  dest = 0 if some_condition > end > > ... > > local_var = 1 > # some_condition evaluates to true > meth(local_var) > > local_var == 0            # should evaluate to true There is no way to do exactly that in Ruby. If you pass the name of the local variable as a string, and pass the binding, you can accomplish something very similar, e.g.: def meth(target, context) result = context.eval target context.eval "#{target} = 0" result end local_var = 1 meth("local_var",binding) # => 1 local_var == 0 # => true --- But this is ugly in many ways. There are better ways of doing out-of-band (e.g., other than the return value) communications back to the caller from a method, like taking a callback function as an argument and passing data to the callback function. You'll probably get better feedback on the best way to achieve what you want in Ruby if you are more specific as to the real goal.