Could someone tell me how I can achieve replacing an element in this 2D array? I tried each, include and replace and wasn't able to figure out where I am going wrong. Thank you in advance for any help.
class Lotto
def initialize
@lotto_slip = Array.new(5) {Array(6.times.map{rand(1..60)})}
end
def current_pick
@number = rand(1..60).to_s
puts "The number is #{@number}."
end
def has_number
#prints out initial slip
@lotto_slip.each {|x| p x}
#Prints slip with an "X" replacing number if is on slip
#Ex: @number equals 4th number on slip --> 1, 2, 3, X, 5, 6
@lotto_slip.each do |z|
if z.include?(@number)
z = "X"
p @lotto_slip
else
z = z
p @lotto_slip
end
end
end
end
test = Lotto.new
test.current_pick
test.has_number
@lotto_slip = Array.new(5) { Array.new(6) { rand(1..60) } }.