You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: subset.rb
    path of file: ./repos/facets/lib/core/facets/hash
    
    the code of the file until where you have to start completion: class Hash

  # Take a subset of the hash, based on keys given or a block
  # that evaluates to true for each hash key.
  #
  #   {'a'=>1, 'b'=>2}.subset('a')            #=> 
    
  def subset(*keys, &block)
    h = {}

    if block
      raise ArgumentError, "subset arguments and block are exclusive parameters" unless keys.empty?
      each do |k, v|
        h[k] = v if block.call(k)
      end
    else
      each do |k, v|
        h[k] = v if keys.include?(k)
      end
    end