From: Massimiliano Mirra Date: 2002-08-04T10:38:37+09:00 Subject: Re: Assoc Class (Hash Pairs) On Sun, Aug 04, 2002 at 09:15:12AM +0900, Tom Sawyer wrote: > 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. That would lead to ambiguity, e.g.: z = { 1 => 'bar', 'foo' => String } What will z[1] mean? Think of Array as a special case of Hash, where keys are integers and are set implicitely when an object is added. With a ordered hash you have two keys, not one, and if you want to access values with the #[] method, it has to know to which key you are referring. > c = 'C'=>'The Letter C' > puts c['The Letter C'] # --> C So are the associations you're thinkin of bidirectional? > a = 'A' > b = 'The Letter A' > > a => b > > puts a.assoc # --> The Letter A Wouldn't that be a.value, according to your examples above? > thus having a way to association objects to one another, sort of like > having varaible variable names. You are thinking in terms of bidirectional links between objects. Take a look at the ZigZag concept, you'll find lots of food for thought. :-) Massimiliano