From: Ken Bloom Date: 2008-01-05T02:40:00+09:00 Subject: Re: iterating over array of variables - can't change them? On Fri, 04 Jan 2008 08:06:38 -0800, 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=""} > > has no effect. > > Why doesn't this work? How can I make it work? > > thanks Refer to the variables as strings and use eval. ["title","subtitle","body"].each {|item| eval "#{item}=''"} --Ken -- Ken (Chanoch) Bloom. PhD candidate. Linguistic Cognition Laboratory. Department of Computer Science. Illinois Institute of Technology. http://www.iit.edu/~kbloom1/