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.
Ruby 1.9 では{1=>2,3=>4}.select{|k,v| v>2}:{3=>4}
{1=>2,3=>4}.select{|k,v| v>2}
{3=>4}
Ruby 1.8 では{1=>2,3=>4}.select{|k,v| v>2}:[[3,4]]
[[3,4]]
{3=>4}1.9と1.8の両方で動作する簡単なコードを書くにはどうすればよいですか?
Hash[{1=>2,3=>4}.select{|k,v| v>2}]