Skip to content

Instantly share code, notes, and snippets.


DNNX/ Secret

Created April 16, 2017 18:22
What would you like to do?

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 }

a = [{cnt: 4}, {cnt: 2}]
f(a, a)

p a
$ rbenv local 2.2.5 && ruby cpp.rb
$ 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