Ruby lookups(=python dict)?

what is the easiest way for a dict like in python?

are there hash tables?

On May 26, 2008, at 7:44 PM, [email protected] wrote:

what is the easiest way for a dict like in python?

are there hash tables?

gen install orderedhash

a @ http://codeforpeople.com/

From: [email protected] [mailto:[email protected]]

what is the easiest way for a dict like in python?

are there hash tables?

yes.

qri Hash

or

http://www.ruby-doc.org/core/classes/Hash.html

in ruby1.9, insertion order is preserved.

kind regards -botp

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

ara.t.howard wrote:

| gen install orderedhash
~ ^^^
Should be ‘gem’. :wink:


Phillip G.
Twitter: twitter.com/cynicalryan
Blog: http://justarubyist.blogspot.com

Make sure input cannot violate the limits of the program.
~ - The Elements of Programming Style (Kernighan & Plaugher)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkg7ayYACgkQbtAgaoJTgL+pgQCfRBr4qrgVY3jS5xzi9441zE57
ZX4AoKN2xXGZBx/jv2et/p+Hz4XE9VDv
=chyJ
-----END PGP SIGNATURE-----

unknown wrote:

what is the easiest way for a dict like in python?

are there hash tables?

The easiest solution is to use a hash, which is built into the language.
This is assuming the order in which the entries are stored within the
hash is unimportant. In very many cases this is true.

dict = {}
dict[“aardvark”] = “a”
dict[“badger”] = “b”
p dict

You don’t have to use strings for keys and values; you can use just
about anything you want.