results = [
{
:id=>2,
:start=> "3:30",
break: 30,
num_attendees: 14,
hello: {hi: 1}
},
{
id: 3,
start: "3: 40",
break: 40,
num_attendees: {hi: 2},
hello: 4
},
{
id: 4,
start: "4: 40",
break: 10,
num_attendees: 40
}
]
Есть ли лучший способ сделать это, избегая нескольких iteration
?
results.each do |hash|
hash.each { |k, v|
hash[k] = "" if v.is_a? Hash
}
end
=> [{:id=>2, :start=>"3:30", :break=>30, :num_attendees=>14, :hello=>""}, {:id=>3, :start=>"3: 40", :break=>40, :num_attendees=>"", :hello=>4}, {:id=>4, :start=>"4: 40", :break=>10, :num_attendees=>40}]
Спасибо