From: trans Date: 2009-03-09T12:07:10+09:00 Subject: Re: Where's the best version of Hash#pass and Hash#block? On Mar 8, 9:48 pm, Phlip wrote: > Rubies: > > This snippet shows how to pass or block arbitrary subsets of Hashes, by their keys: > >    http://snippets.dzone.com/posts/show/2178 > > Those items seem useful, because Hashes are not as set-theoretic as Arrays. I > suspect, for example, one cannot & two Hashes to extract their intersection. > > That post is from 2006 - essentially the Neolithic Era! > > Where's the best modern version of those methods? From Facets: def slice(*keep_keys) h = {} keep_keys.each do |key| h[key] = fetch(key) end h end def except(*less_keys) slice(*keys - less_keys) end T.