I've been looking at this of late,

what I want is ;

class Hash
  def map_pairs
    new_hash = self.class.new  # works in HashWithIndifferentAccess
    self.each do |key, value|
      new_key, new_value = yield(key, value)
      new_hash[new_key] = new_value
    end
    return new_hash
  end

  def map_values
    new_hash = self.class.new
    self.each do |key, value|
      new_hash[key] = yield(key, value)
    end
    return new_hash
  end
end

is that a bad idea?
does "map" have to return an array?

-- 
Posted via http://www.ruby-forum.com/.