Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私のコードは
a={"1"=>"adi","2"=>"amar","3"=>"rave","4"=>"sum"} arr=["1","5","3"]
配列値がハッシュに存在する場合、このようにすべての値を抽出したい
result =["adi","rave"]
ループを使用せずに。可能ですか
あなたがすることができます:
a.values_at(*arr).compact # => ["adi", "rave"]