From: dempsejn@... Date: 2001-12-18T05:07:37+09:00 Subject: [ruby-talk:28817] Re: array.to_h wow...it really does get easier...thanks so much! Jack ----- Original Message ----- From: Joel VanderWerf Date: Monday, December 17, 2001 3:02 pm Subject: [ruby-talk:28816] Re: array.to_h > dempsejn@georgetown.edu wrote: > > > > with to_a it is possible to create an array from a hash...is > there a function to do the > > opposite? > > > > a = [1,2,3,4] > > hash = a.to_h # h = {1=>2, 3=>4} > > > > perhaps there's a shortcut and that's where there's no to_h > function, but i'm curious > > thanks! > > Jack > > h = Hash[*[1, 2, 3, 4]] > or > h = Hash[*a] > > -- > Joel VanderWerf California PATH, UC Berkeley > mailto:vjoel@path.berkeley.edu Ph. (510) 231-9446 > http://www.path.berkeley.edu FAX (510) 231-9512 >