From: "Joachim (München)" Date: 2008-04-10T20:05:07+09:00 Subject: Re: Hash insertion order preservation in ruby1.9 On 2 Apr., 03:39, Nobuyoshi Nakada wrote: > Hi, > > At Mon, 31 Mar 2008 19:55:12 +0900, > Joachim (München) wrote in [ruby-talk:296442]: > > > (4) Once hashes are ordered, new use cases will be found, and > > new methods will become useful. I would like to propose the following > > new instance methods > > Hash#insert_before( existing_key, other_hash ) > > Hash#insert_after( existing_key, other_hash ) > > and possibly also > > Hash#insert_before( existing_key, key, value ) > > Hash#insert_after( existing_key, key, value ) > > to insert new items at well defined locations. My use case, as I > > said before, is a hash which is dumped into human-readable yaml. > > What do you expect on conflicts? > > -- > Nobu Nakada Sorry Nobu, I saw your question only today. I see two possible conflicts: - existing _key does not exist - key already exists Right? I would raise an exception in both cases. Rationale: One could imagine several other ways to resolve conflicts. I do not think one of them will be widely accepted as the obvious right thing to do. Therefore not attempting to reconcile conflicts will cause the least surprise. Regards, Joachim