Create a gist now

Instantly share code, notes, and snippets.

@DNNX / README.md Secret
Created Apr 16, 2017

Embed
What would you like to do?
excellent-bonus

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
[]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment