标签: ruby hash
Ruby文件:
student_ages = { "Jack" => 10, "Jill" => 12, "Bob" => 14 }
如何从哈希中选择杰克和吉尔对?
student_ages.select {|key| k.length <= 4}
答案 0 :(得分:6)
student_ages.select{|key, _| key.length == 4}