rand method

Is the range option only available for later Ruby Versions than the Maker(VX Ace) has or why i cant do this:

rand(1..10)

?

Thanks for help.
I believe you can do rand(x) which gives you a number between 0 and x-1. So 7+rand(6) would give you a number between 7 and 12 (7+5).
The following code will allow for a range within Random :

Code:
Random.new.rand(x..y)
Thank you both!
Code:
require 'Benchmark'n = 100000Benchmark.bmbm do |x|  x.report("Random.new.rand") {    n.times { Random.new.rand(1..10) }  }    x.report("rand with math") {    n.times { rand(10) + 1 }  }end
Results

Code:
Rehearsal ---------------------------------------------------Random.new.rand   9.407000   6.880000  16.287000 ( 16.298932)rand with math    0.031000   0.000000   0.031000 (  0.036002)----------------------------------------- total: 16.318000sec                      user     system      total        realRandom.new.rand   8.861000   7.425000  16.286000 ( 16.294932)rand with math    0.031000   0.000000   0.031000 (  0.036002)
You'd probably want to store an instance of Random somewhere

Code:
Benchmark.bmbm do |x|  x.report("Random.new.rand") {    r = Random.new    n.times { r.rand(1..10) }  }}
Code:
Random.new.rand   0.047000   0.000000   0.047000 (  0.040002)
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/rand-method.18639/