Files
  • main.rb
main.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class Hash
  def keys_of(*arguments)
    new_array = []
    self.each do |key, value|
      #puts arguments
      #puts key
      if value == arguments
        new_array << key 
      end
    end
    new_array
  end
end

animals = {"sugar glider"=>"Australia","aye-aye"=> "Madagascar","red-footed tortoise"=>"Panama","kangaroo"=> "Australia","tomato frog"=>"Madagascar","koala"=>"Australia"}

animals.keys_of('Madagascar')
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux]