I have:
array1 = [:blue, :blue, :blue, :blue]
array2 = [:green, :green, :yellow, :red]
I am trying to count how many blue symbols are in array2
, which is 0
. I did:
near_matches = 0
array1.each do |color1|
if array2.count(color1)
near_matches += 1
end
end
near_matches #=> 4
There are no matching color symbols in array1
with array2
, and yet I still get 4
as an output. I was wondering why the output of my code is 4
.