From: Mark Van Holstyn Date: 2006-08-12T08:20:13+09:00 Subject: Re: Beginner's question: assigning same value to many variables ------=_Part_123833_30210437.1155338409657 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline or you could do %w{ a b c d e f g h i j }.each {|v| eval "#{v}=''" } On 8/11/06, Mark Van Holstyn wrote: > > a=b=c=d=f=g=h=i=j=k=l=m=n='' > > > > > On 8/11/06, Alex Khere wrote: > > > > I'm just starting out in programming, using Ruby to learn. > > > > I'm trying to write a short program that will use a handful of > > variables, and I want to be sure that all of the variables start with > > the value '' (strings of zero length). > > > > Is there a way to list all of the variables on a single line and set > > them to the same value? I tried using commas to seperate, but that > > didn't work. > > > > I also tried creating an array with all of the variable names and then > > using "arrayname.each do |name|" to cycle through the assignment, but > > since the varibles hadn't been defined, I got an "undefined local > > variable or method" error (at least, I think that's why I got an error). > > > > > > > > -- > > Posted via http://www.ruby-forum.com/. > > > > > > > -- > Mark Van Holstyn > mvette13@gmail.com > http://lotswholetime.com > -- Mark Van Holstyn mvette13@gmail.com http://lotswholetime.com ------=_Part_123833_30210437.1155338409657--