P
Size: a a a
P
P
P
w
w
CM
irb(main):001:0> buff = Hash.new(0)
=> {}
irb(main):002:0> buff[:hello] += 1
=> 1
irb(main):003:0> buff[:there] += 4
=> 4
irb(main):004:0> buff
=> {:hello=>1, :there=>4}
CM
w
line_items.inject({}) do |tax_groups, line_item|
if tax_groups.key?(line_item["tax_lines"])
tax_groups[key].push(line_item)
else
tax_groups[key] = [line_item]
end
tax_groups
end
CM
each_with_object(Hash.new(0))
v
w
v
each.with_object(Hash.new(0)) do |k, o|
o[k] += 1
end
VA
each_with_object(Hash.new([])) do |line_item, tax_groups|
tax_groups[key] << line_item
end
w
w
VA
w
CM
tax_groups[key] ||= []
tax_groups[key] << line_item
sh.new(default) м
еняет структуру, когда ты пытаешься к ней обратиться. забудешь — можешь нарожать новых ключей ненужныхw