2016-03-16 71 views

回答

4
people.delete_if{|element| element['name'] == 'Bill'} 
# => [{"name"=>"Jim", "car"=>"Porche", "houseSize"=>"big"}] 

順便說一句:你的哈希值缺少一些逗號。

people = [ 
    { 
    'name' => "Jim", 
    'car' => "Porche", 
    'houseSize' => "big" 
    }, 
    { 
    'name' => "Bill", 
    'car' => "Honda", 
    'houseSize' => "small" 
    } 
]