From: Bill Guindon Date: 2004-09-06T08:50:15+09:00 Subject: Re: OK... :) question about hash and array literals On Mon, 6 Sep 2004 08:31:38 +0900, Hal Fulton wrote: > Yukihiro Matsumoto wrote: > > Are there any reason to make hash literals not to guarantee order? > > I thought > > > > h = {1=>2, 3=>4} > > > > will preserve the order, when ordering is implemented. > > Oh! I misunderstood completely, then. > > My original understanding was that > > {1=>2, 3=>4} == {3=>4, 1=>2} > > implied that order was not preserved in literals. It would depend on what the ordering is used for, no? If ordering is only used to feed 'next', then the compare above would still be true. Personally, I'd like it to remember the order you added things in, use that ordering when iterating through the hash, and _optionally_ use it for compares. Something like... {1=>2, 3=>4} == {3=>4, 1=>2} {1=>2, 3=>4}.ordered != {3=>4, 1=>2}.ordered -- Bill Guindon (aka aGorilla)