I’m trying to count items in an array by comparing to objects in a 2d array but the outcome is incorrect and I can’t see why. The only reason I can see is that it’s comparing addresses rather than values.
#@rules[0][0] contains 1
#@items contains [1,1]
@items = [1,1]
@rules = Array.new() {Array.new}
@rules.push([])
@rules[0].push(1)
actualFreq = @items.count(@rules[0][0])
puts actualFreq # should be 2 but outcome is 0
I fixed this by using: