From: El Gato Date: 2006-11-21T11:32:05+09:00 Subject: Re: How to put array into variables Ken Allen wrote: > This also works: > b = "word1 word2" > ((a,b)) = b.scan(/^(\w+)\s(\w+)$/) > p a => "word1" > p b => "word2" > > The outer parens matches the outer array, and the inner parens matches > the inner array, allowing a and b to decompose it. > It's a pretty useful trick when decomposing nested arrays. > > Ken Seems like the long way around... foo = ["one", "two"] a, b = foo a #=> "one" b #=> "two" -- Posted via http://www.ruby-forum.com/.