Get Multiple Values From Hash In Very Efficient Way
hash, ruby
Solution
You could do:
a.values_at(*arr).compact
# => ["adi", "rave"]
Problem
My code is ``` a={"1"=>"adi","2"=>"amar","3"=>"rave","4"=>"sum"} arr=["1","5","3"] ``` I want to extract all values like this if array values exist in the hash ``` result =["adi","rave"] ``` without using any loop.Is it possible