def num_exact_matches (guess_code)
num_of_exact = 0
guess_code.each_with_index { |char, index| num_of_exact += 1 if char.upcase == @pegs[index] }
end
when I wrote this code, this error happens
undefined method “each_with_index” for #<Code:0x00007fffb8982668 @pegs=[“R”, “Y”, “Y”, “B”]>
It would depend on what you’re passing into the num_exact_matches
method.
Your error is basically telling you, "whatever you put in the guess_code
variable does not have a method called each_with_index
I don’t know the master mind project, unfortunately, but it appears that you probably want to pass the pegs
into the method? Either that, or the num_exact_matches
is intended to grab the pegs out of the guess_code
…
Hope that helps!