From: Andrew Walrond Date: 2005-04-24T02:04:00+09:00 Subject: Re: Suggestion: Hash.remove On Saturday 23 April 2005 15:37, Florian Gro� wrote: > Andrew Walrond wrote: > > Something I often find useful is a version of Hash.delete which returns > > the hash rather than the deleted item. Useful for terse chained code. > > You want to do hash.delete("foo").delete("bar").delete("qux"). Yes, but more usually just an assignment: attribs = {'version'=>version}.update(@versions[version]).remove('files') > > Why don't you do this? > > %w(foo bar qux).each do |key| > hash.delete(key) > end > Because small code is often beautiful code, and I never use three lines to do a one line job ;) > New keys can easily be added and is not repetitive at all. > > Perhaps you could instead change your proposal to make .delete() accept > multiple keys? That would definately be a good, backwardly compatible setp. Andrew