From: "Shot (Piotr Szotkowski)" Date: 2009-03-30T01:05:10+09:00 Subject: Is there an idiom for mass-populating Hash keys? --ADZbWkCsHQ7r3kzd Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello, good folk of ruby-talk. I was wondering whether there=E2=80=99s a Ruby idiom to mass-populate keys of a Hash. I=E2=80=99m coding a graph class supporting labeled vertices, and I want to= =20 represent this relationship as a @vertices Hash, with keys being the=20 actual vertices and values being their labels =E2=80=93 initially all nil: class Graph def initialize enum @vertices =3D {} enum.each { |vertex| @vertices[vertex] =3D nil } end end Is there a more elegant way to take an enum and turn it into nil-referencing Hash keys? =E2=80=94 Shot --=20 >> The Ruby community should proceed with all deliberate >> speed towards ISO standardization of the language. > Yeah, look what it did to Forth. Don=E2=80=99t just say it, show it. http://vividpicture.com/aleks/atari/for= th.jpg [M. Edward (Ed) Borasky, Matt Lawrence, Gregory Brown, ruby-talk] --ADZbWkCsHQ7r3kzd Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAknPlXAACgkQi/mCfdEo8UphowCeMm3Bbhx3lpthUATpfrYynuNw eW8An0rxmTaCYtliVch57PsEewbMWEcv =01u1 -----END PGP SIGNATURE----- --ADZbWkCsHQ7r3kzd--