From: Joshua Ballanco Date: 2008-11-26T13:19:14+09:00 Subject: Re: How to use a passing argument(returned argument)? On Nov 25, 2008, at 8:49 PM, 김 준영 wrote: > Hello, everyone !!! Hi there! > I have question about how to use a passing argument. firstly let me > show sample code. > > a = 0 > > def set10(aArg) > aArg = 10 > end > > set10(a) > > p a <--- I wanna get 10 as a result. > > > How can I do for this one? First, the pattern you are looking for is not very object oriented-y. That is, you're asking to remove some of the logic pertaining to 'a' and put it somewhere outside of 'a'. Since 'a' is an object (everything in Ruby is), then it would be best if you made 'a' an instance of a class with the 'set10' logic in it. The sort of pass-by- reference pattern you're looking for is much more typical of C. That said, this would be, I think, the closest equivalent in Ruby: a = 0 def set10(aArg_name, bind) eval("#{aArg_name} = 10", bind) end set10('a', binding) p a => 10 Cheers, Josh