From: Aleksey V Zapparov Date: 2012-06-24T18:28:37+09:00 Subject: Re: Stripping symbol character from hash turned to array --Sig_/QgOSUM57zD2nxKcPGAJQmns Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Sun, 24 Jun 2012 10:38:28 +0900 Emeka Patrick wrote: > Hi, new to programming and Ruby and trying to work through some > problems and understand the language. Right now I'm doing work with > hashes and ran into a question. >=20 > Took this Hash >=20 > people =3D { > :fred =3D> 23, > :joan =3D> 18, > :pete =3D> 54 > } >=20 > and turned it to an Array via "people_array =3D people.to_a" >=20 > now I have >=20 > people_array =3D [[:fred, 23], [:joan, 18], [:pete, 54]] You can iterate through them all if you really need it: people_array.to_a.map{ |a| a.map(&:to_s) } But, I don't see any point to do so, as for example if you want stringify this Hash - all symbols will automatically become strings and so on. Also if you'll need to output this as a list: people_array.to_a.each do |pair| name, age =3D pair puts "#{name} is #{age} years old" end *Disclaimer: the code above demonstrates work with symbols, not iterating through Hash or Array --=20 Sincerely yours, Aleksey V. Zapparov A.K.A. ixti FSF Member #7118 Mobile Phone: +34 677 990 688 Homepage: http://www.ixti.net JID: zapparov@jabber.ru *Origin: Happy Hacking! --Sig_/QgOSUM57zD2nxKcPGAJQmns Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQEcBAEBAgAGBQJP5t2/AAoJEGRO9nGLm9Y8Yh8H/3d+qxtKpEbx5bLQTrt6fUbb vIuBiFCbv7Mk8XNig99JFQIy3vRvf06D//Cln85qgnvPYtrRzLhr32TUIZmpfD2E 3dpAO1dQlfGtb5R3AxhH0Z/dJzOW4jtCj8KRbvphbP/ADPHUXtRKImCfd6ePbcHP Jb9vB5qGXEQLBoXrD2o74knjZEcmAOEFdSc/8Kk1GDIq74yZ7M9t4KrYT1/6/oEe DTPd76LGR0GaIJrn8+Ssi4Fw8nneiK/ANyzCGtGZ2GZqssaJy1HY2tqashcFgpq8 LwTIlpLVWfoN2fckD7M0Yj1To9//Q8y+OBnLNj7F4VLxlryUeTpxtiIb5yL8IjI= =wA1z -----END PGP SIGNATURE----- --Sig_/QgOSUM57zD2nxKcPGAJQmns--