From: Philip Hallstrom Date: 2007-07-26T03:58:39+09:00 Subject: Re: Question - Passing parameters by reference > On Thu, 26 Jul 2007, Chris Thiel wrote: > >> What if the method is returning something else already and you don't want >> to have to return the changed value? How do you pass in a variable to a >> method and have the change stick when it exists the method in ruby? > > You can change an object: > > def change_me(str) > str.upcase! > end > > s = "abc" did you mean to say... s = str = "abc" ? > change_me(str) > puts s # ABC > > But you can't change the bindings. In the example, I've got s and str > both containing references to the same string. But the names of the > identifiers themselves, s and str, are solely the business of their > local scopes, which are different as between the method body and the > calling context. > > > David > > -- > * Books: > RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242) > RUBY FOR RAILS (http://www.manning.com/black) > * Ruby/Rails training > & consulting: Ruby Power and Light, LLC (http://www.rubypal.com) > >