Ruby Random Numbers Of A Specific Length
Join the DZone community and get the full member experience.
Join For Free// generate random numbers of a specific number of digits
rand.to_s[2..10] #=> 8 digit long random number
rand.to_s[2..6] #=> 4 digit long random number
Opinions expressed by DZone contributors are their own.
Comments