Hi --

On Wed, 21 Sep 2005, Bil Kleb wrote:

> I've got a mental block on refactoring the following,
>
> # given a hash of arrays,
> hash = { 1=>[:a,:b,:c], 2=>[:d,:e], 3=>[:a,:c] }
>
> # remove a specified element from the arrays if present
> hash.each{ |k,v| hash[k] = v.delete_if{|e| e==:a} }
>
> => { 1=>[:b,:c], 2=>[:d,:e], 3=>[:c] }
>
> Isn't there a simpler way to remove the matching
> elements?  (Maybe my data structure is just lame?)

Slightly simpler:

   hash.values.each {|v| v.delete(:a) }


David

-- 
David A. Black
dblack / wobblini.net