Skip to content

Instantly share code, notes, and snippets.

@jasoncodes
Forked from benhoskings/Hash#selekt.rb
Created March 29, 2010 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasoncodes/348451 to your computer and use it in GitHub Desktop.
Save jasoncodes/348451 to your computer and use it in GitHub Desktop.
class Hash
def selekt
inject({}) {|hsh,(k,v)|
hsh[k] = v if yield(k,v)
hsh
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment