The correct answer is: it depends. Depends on the version of Ruby you're running currently and possibly some other factors.
# cpp.rb
def f(xs, ys)
xs.reject! do |x|
ys.any? { |y| y[:cnt] += x[:cnt] if x != y }
end
end
a = [{cnt: 4}, {cnt: 2}]
f(a, a)
p a
$ rbenv local 2.2.5 && ruby cpp.rb
[{:cnt=>6}]
$ rbenv local 2.3.3 && ruby cpp.rb
[]