From: dblack@... Date: 2007-05-09T19:55:24+09:00 Subject: Re: newbie: assign values/array to variables Hi -- On Wed, 9 May 2007, Mark V wrote: > Hi, > Thanks for all the fantastic work that has gone into ruby. Even > though I am new it has proved to be very impressive. > To my question. > I've seen the following code: > > @vara, @varb = "ab,ac,ad,ae".split(",") > > the way @vara and @varb were used makes me think the writer expected > the following: > > puts @vara.inspect # "ab" > puts @varb.inspect # ["ac", "ad", "ae"] > > However when I run this code I get > > puts @vara.inspect # "ab" > puts @varb.inspect # "ac" > > Is there a way to achieve the writer seemed to have in mind? Yes: @vara, *@varb = "ab,ac,ad,ae".split(",") David -- Q. What is THE Ruby book for Rails developers? A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) (See what readers are saying! http://www.rubypal.com/r4rrevs.pdf) Q. Where can I get Ruby/Rails on-site training, consulting, coaching? A. Ruby Power and Light, LLC (http://www.rubypal.com)