title: in Ruby, how to extract a key from the Hash having the value
body: <p>i thought i'm a Ruby giant when i wrote this oneliner:</p>
  
  <pre><code># having this hash
  hash = { 'Portugal' =&gt; 1, 'France' =&gt; 2, 'USA' =&gt; 3 }
  
  # country_id comes from input
  country_name = (hash.select { |k,v| v == country_id.to_i }.first || []).first
  </code></pre>
  
  <p>it does correctly extract the country name and does Not fail if country not found.</p>
  
  <p>i'm totally pleased with it.</p>
  
  <p>however my tutor says it can/should be optimized in terms of readability, length and performance!</p>
  
  <p>what can be clearer/faster than this?</p>
  
  <p>please advise</p>