From: Radek Hnilica Date: 2002-06-07T22:04:59+09:00 Subject: Re: How to create one hash from two arrays --gE7i1rD7pdK0Ng3j Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > How can I simply build one hash from two arrays. One containing keys > and second containing values. >=20 > keys =3D ['a', 'b', 'c'] > vals =3D [1, 2, 3] >=20 > h =3D {'a'=3D>1, 'b'=3D>2, 'c'=3D>3} After sending question I found this solution keys =3D res.fields vals =3D res.result[0] h =3D Hash.new(nil)=09 0.upto(keys.length) do |i| h[keys[i]] =3D vals[i] end return h but, could it be simpler? --=20 Radek Hnilica =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D No matter how far down the wrong road you've gone, turn back. Turkish proverb --gE7i1rD7pdK0Ng3j Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE9ALCnk1fyNKgnP8QRAnySAJ9f1Fz4HRZQbd9aBf7IGCdVwf5kpwCeIM2a mtW5LHHAgBMvdqggdHBB/4k= =ksfD -----END PGP SIGNATURE----- --gE7i1rD7pdK0Ng3j--