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.
rand(1..10)
?
Thanks for help.
Random.new.rand(x..y)
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
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)
Benchmark.bmbm do |x| x.report("Random.new.rand") { r = Random.new n.times { r.rand(1..10) } }}
Random.new.rand 0.047000 0.000000 0.047000 ( 0.040002)
Original thread: https://forums.rpgmakerweb.com/threads/rand-method.18639/