I need a little help

I will just need a small information about scripts XP ^ ^

I have this: @ var1 = rand (57)

 

So @ var1 (this is a local variable, but it has no interest in the issue.) Will have a random value between 0 and 56.

What I'd like to know is, what is the term that allows Ruby to say such and such a value between.

(so for example: rand (15 and 75))
To create a random number with a minimum range >0, you'll need to add the minimum to a random on the difference (in almost all programming languages, doesn't matter if Ruby or C/Pascal/others.

In your example, that would be:

= 15 + rand(60)

(because 60 is the difference between 15 and 75)
I've moved this thread to Learning Ruby and RGSSx. Please be sure to post your threads in the correct forum next time. Thank you.
Another method is Random.new.rand(min..max), where min is your minimum number and max is your maximum.

A shorter method is also Random.rand(min..max), and I've seen some online posts (mostly on StackOverflow) say this is better, but I've never seen a technical explanation why -- only that Random.new.rand generates a new seed every time it's used and this is somehow a bad thing. I don't get why but that's how it goes.

tl;dr - Random.new.rand(min..max) or Random.rand(min..max) work fine.
http://forums.rpgmakerweb.com/index.php?/topic/18639-rand-method/#entry179583


Random.new.rand is pretty slow. If you're doing it once and that's it then that's ok I guess.......
(1..10).to_a.sample.to_i

Original thread: https://forums.rpgmakerweb.com/threads/i-need-a-little-help.19021/