Monthly Archives: April 2009

When you get really bored, and want to find a problem for this solution:

Getting the intersection and lowest values of a hash. def hash_intersect_min(*hashes) hashes.inject(hashes.pop.dup) { |i,h| i.delete_if { |k,v| hv=h[k]; next true unless hv; i[k]=hv if hv<v; false }; i } end So the following: hash_intersect_min({:a => 1, :d => 2, :k … Continue reading

Posted in Uncategorized | Leave a comment