Trans wrote: > Daniel Schierbeck wrote: >> nobu / ruby-lang.org wrote: >>> Hi, >>> >>> At Thu, 17 Aug 2006 04:05:08 +0900, >>> Daniel Schierbeck wrote in [ruby-talk:208833]: >>>> Probably somewhat slower, but hey, it lets you do this >>>> >>>> a, b, c = hsh.delete :a, :b, :c >>> What will be returned from `hsh.delete :a'? >> The value of :a >> >> hsh = {:a => 1, :b => 2, :c => 3} >> hsh.delete :a, :b #=> [1, 2] >> hsh.delete :c #=> 3 >> >> that way, you can do this >> >> a = hsh.delete :a >> b, c = hsh.delete :b, :c >> >> Cool, right? > > Ah, Nobu has a good point. It's beeter to have same kind of output. He > also jogs my memory. Array has #delete_values_at and that's what we > need for Hash too. > > def delete_values_at(*keys, &block) > keys.map{|key| delete(key, &block) } > end > > Kind of long name though, maybe #delete_at would suffice? Read my mind... yes, I think there should be added a #delete_at method in addition to the new #delete. Cheers, Daniel