Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
class method
Random.rand
Random.rand → float
Random.rand(max) → number
Random.rand(range) → number
random.c
View on GitHub ↗
static VALUE
random_s_rand(int argc, VALUE *argv, VALUE obj)
{
VALUE v = rand_random(argc, argv, Qnil, rand_start(default_rand()));
check_random_number(v, argv);
return v;
}
Returns a random number using the Ruby system PRNG.
See also Random#rand.
Ruby version changes
-
3.0
-
Random::DEFAULTis deprecated since its value is now confusing and it is no longer global, useKernel.rand/Random.randdirectly, or create aRandominstance withRandom.newinstead. [Feature #17351]
-