reject snippets

Ruby Hash except and only

Tagged hash, ruby, except, only, reject  Languages ruby
class Hash
  def except(*blacklist)
    reject {|key, value| blacklist.include?(key) }
  end

  def only(*whitelist)
    reject {|key, value| !whitelist.include?(key) }
  end
end