Ruby Newbee wrote:
> Helo,
> 
> How to convert an array to a hash?
> for example,
> 
>> x
> => ["a", "hello", "b", "world", "c", "welcome", "d", "baby"]
> 
> to:
> 
>> z
> => {"a"=>"hello", "b"=>"world", "c"=>"welcome", "d"=>"baby"}
> 
> 
> 
> And, for creating an array quickly, I could say:
> 
> x = %w/a hello b world c welcome d baby/
> 
> but how to creat a hash like this way?

I'm not sure why you want to do this in the first place, but check out 
the each_slice method.


> 
> 
> Thanks.

Best,
--
MarnenLaibow-Koser
http://www.marnen.org
marnen / marnen.org
-- 
Posted via http://www.ruby-forum.com/.