title: Hash map in ruby is storing key-value pair automatically
body: <p>This is generally a way to create a <code>Hash Map</code> in Ruby</p>
  
  <pre><code>colors = {
  
  "red" =&gt; 2, 
  "blue" =&gt; 3
  
  }
  </code></pre>
  
  <p>But in below code, where did Key and its corresponding value is specified, like it was done in "colors" hash.</p>
  
  <pre><code>puts "enter a string"
  text = gets.chomp
  words=text.split
  frequencies = Hash.new(0)
  words.each {|word| frequencies [word] +=1}
  frequencies = frequencies.sort_by do |wordy, wcounty|
      wordy
  end
  puts frequencies
  </code></pre>
  
  <p>Is it done in each loop or in line next to it where "frequencies" new value is assigned as a loop, if Yes , how?</p>
  
  <p>I am new to <code>Ruby</code> but I have little knowledge of <code>JAVA</code>, so its difficult for me to understand.</p>