我有一个哈希数组,我想迭代并标题化这样的元素:
@customer_activities.each do |activity|
activity['name'].titleize
end
如何确保activity['name'].titleize
的结果最终影响@customer_activities
中的条目?
答案 0 :(得分:3)
@customer_activities.each do |activity|
activity['name'] = activity['name'].titleize
end