From: Joel VanderWerf Date: 2001-12-18T05:02:21+09:00 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