From: m4dc4p Date: 2005-12-13T09:12:38+09:00 Subject: Re: Way to combing Hash Definition sans => with %w() ? Was this question a ringer or what? Seriously, I love how easy Ruby makes some things. Come on Matz, fess up - this was a plant! :) James Edward Gray II wrote: > On Dec 12, 2005, at 5:25 PM, Dan Diebolt wrote: > > > I have a large amount of text pairs (no spaces inthe text) that I > > need to turn into a hash. Is there a shorcut that will allow me to > > create the hash without entering the quotes and arrows? > > > > %w(apple bananna orange grape) > > => ["apple", "bananna", "orange", "grape"] > > > > Hash["apple","bananna","orange","grape"] > > =>{"apple"=>"bananna", "orange"=>"grape"} > > >> Hash[*%w(apple bananna orange grape)] > => {"apple"=>"bananna", "orange"=>"grape"} > > James Edward Gray II