From: Daniel Schierbeck Date: 2006-08-17T18:30:11+09:00 Subject: Re: Multiple arguments for Hash#delete Trans wrote: > Daniel Schierbeck wrote: >> This may be a Facet: >> >> class Hash >> alias_method :__delete__, :delete >> >> def delete(*keys, &block) >> if keys.length == 1 >> __delete__(keys.first, &block) >> else >> keys.map{|key| __delete__(key, &block) } >> end >> end >> end >> >> Probably somewhat slower, but hey, it lets you do this >> >> a, b, c = hsh.delete :a, :b, :c >> >> which fits in nicely with >> >> hsh[:a, :b, :c] = 1, 2, 3 >> >> and >> >> a, b, c = hsh[:a, :b, :c] > > Good deal. I'll add it. Looks to be a safe override too. For once... :) > Perhaps this is a good update for future version of Ruby? I think the updated #[], #[]= and #delete all deserve to be in core. The only problem I see is performance-wise, although implementing them in C might help there. Cheers, Daniel