PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > ruby lookups(=python dict)?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
ruby lookups(=python dict)?

Réponse
 
LinkBack Outils de la discussion
Vieux 27/05/2008, 02h43   #1
notnorwegian@yahoo.se
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut ruby lookups(=python dict)?

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

are there hash tables?

  Réponse avec citation
Vieux 27/05/2008, 02h48   #2
ara.t.howard
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: ruby lookups(=python dict)?


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://codeforpeople.com/
--
we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama




  Réponse avec citation
Vieux 27/05/2008, 02h57   #3
Peña, Botp
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: ruby lookups(=python dict)?

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/Hash.html

in ruby1.9, insertion order is preserved.


kind regards -botp

  Réponse avec citation
Vieux 27/05/2008, 02h59   #4
Phillip Gawlowski
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: ruby lookups(=python dict)?

-----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.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+pgQCfRBr4qrgVY3 jS5xzi9441zE57
ZX4AoKN2xXGZBx/jv2et/p+Hz4XE9VDv
=chyJ
-----END PGP SIGNATURE-----

  Réponse avec citation
Vieux 27/05/2008, 12h23   #5
Dave Bass
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: ruby lookups(=python dict)?

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-forum.com/.

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h19.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10722 seconds with 13 queries