I want to have 2 variables which point on a random number between 1 and 10, but the 2 variables must point on different values, I don’t want both of them to value 5 or another value at the same time. So I wrote this method:
def give_a_value
@num_array.each do |num|
value=1+rand(10)
if value==num
give_a_value
end
end
@num_array.push(value)
value
end
@num_array=[0]
var1=give_a_value
var2=give_a_value
The problem is that it doesn’t work. It seems like the program doesn’t enter the loop ôO. I’ve been thinking about this for some days and I still don’t find the solution, so I ask for your help.