D
Daniel Schierbeck
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]
Cheers,
Daniel
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]
Cheers,
Daniel