Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Off by 1 error #9

Open
Kostadin opened this issue Aug 27, 2014 · 1 comment
Open

Off by 1 error #9

Kostadin opened this issue Aug 27, 2014 · 1 comment

Comments

@Kostadin
Copy link

In the file
lib/json-compare/comparer.rb
at line 60:

  old_array_length = old_array.count
  new_array_length = new_array.count
  inters = [old_array.count, new_array.count].min

  result = get_diffs_struct

  (0..inters).map do |n|
    res = compare_elements(old_array[n], new_array[n])
    result[:update][n] = res unless (res.nil? || (res.respond_to?(:empty?) && res.empty?))
  end

I think the interval should be
(0..(inters-1)) instead of (0..inters)

@kerrizor
Copy link

kerrizor commented Dec 8, 2014

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants