From: Tomaso Tosolini Date: 2008-01-05T01:25:00+09:00 Subject: Re: iterating over array of variables - can't change them? AJS wrote: > title="Title" > subtitle="Subtitle" > body="Body" > [title,subtitle,body].each {|item| item.downcase!} > > This successfully sets the original variables to "title", "subtitle", > "body" > > BUT > > [title,subtitle,body].each {|item| item=""} Hi item="" sets item to reference to another string instead of the original at the beginning of the block try this [title,subtitle,body].each {|item| x = item item="" # this make item go to point away from it's original value p x.inspect # but x hasn't lost it's reference to initial value so it still #works } Tom > > has no effect. > > Why doesn't this work? How can I make it work? > > thanks