From: Tom Sawyer Date: 2002-08-04T09:15:12+09:00 Subject: Re: Assoc Class (Hash Pairs) On Sat, 2002-08-03 at 16:40, Hal E. Fulton wrote: > Well, it's ordered, all right; but is it really a hash > any more? E.g., could you still get this to work? > > z = ordhash['a'] # equals 1 > > Not without changing the [] method of Array. And if you > change it in such a way, you're making Array into Hash. no, not exactly. it's still array. you'd have to say: z = ordhash[0]['a'] or z = ordhash[0].value although it may not be out of the question to give Array a little more smarts to do what you are suggesting. then certainly this would supplant the regualar Hash class. also i have a notion that these associations may actually be useful on their own. a = 'A'=>'The Letter A' b = 'B'=>'The Letter B' c = 'C'=>'The Letter C' puts a.index # --> A puts b.value # --> The Letter B puts a['A'] # --> The Letter A puts c['The Letter C'] # --> C but as for being especially useful? who knows what others might dream up. i could use it for complex hierarchies. someone else might find another use. taking it a bit further, i realize i'm also leaning toward something more. sort of an alternative to assingment: a = 'A' b = 'The Letter A' a => b puts a.assoc # --> The Letter A thus having a way to association objects to one another, sort of like having varaible variable names. just thinking out loud at this point. -- ~transami