[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

ruby lookups(=python dict)?

slix

5/27/2008 1:44:00 AM

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

are there hash tables?

4 Answers

ara.t.howard

5/27/2008 1:48:00 AM

0


On May 26, 2008, at 7:44 PM, notnorwegian@yahoo.se wrote:

> what is the easiest way for a dict like in python?
>
> are there hash tables?
>
>

gen install orderedhash

a @ http://codeforp...
--
we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama




Peña, Botp

5/27/2008 1:57:00 AM

0

From: notnorwegian@yahoo.se [mailto:notnorwegian@yahoo.se]=20
# what is the easiest way for a dict like in python?
# are there hash tables?

yes.

qri Hash=20

or=20

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

in ruby1.9, insertion order is preserved.


kind regards -botp

Phillip Gawlowski

5/27/2008 2:00:00 AM

0

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

ara.t.howard wrote:

| gen install orderedhash
~ ^^^
Should be 'gem'. ;)

- --
Phillip Gawlowski
Twitter: twitter.com/cynicalryan
Blog: http://justarubyist.bl...

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....

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

Dave Bass

5/27/2008 11:24:00 AM

0

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.
--
Posted via http://www.ruby-....