I am using
rand(200)
in my Rails application. When I run it in console it always returns random number, but if I use it in appl
rand(200) is run once and that value is assigned to your index
variable. So 'index' will always be that number.
If you want index
to change, you will need to continually run rand on it.
Here's a simple way to do that:
def randomIndex(num)
index = rand(num)
return index
end
randomIndex(200)
=> // this value will change