I want to generates a sequence of unique random number between 100 and 999. I want to make sure that no numbers are generated twice, to ensure that each number is unique. Here is what I came up with. It does not work. When i run it, the screen is just blank. Can anyone help me?
products = {}
def random_key(products)
rand_key = rand(900) + 100
while products.has_key?(rand_key)
rand_key = rand(900) + 100
end
end
puts random_key(products)