do you know how I can get a random number in the specified range?
like what this shell command does:
$ shuf -i 10000-99999 -n 1
19869
Thank you in advance.
do you know how I can get a random number in the specified range?
like what this shell command does:
$ shuf -i 10000-99999 -n 1
19869
Thank you in advance.
You can provide a range to the `rand` method.
eg. `rand 10000..99999`
On Sat, Oct 1, 2022 at 7:07 PM Henrik Pang <henrik@simplemail.co.in> wrote:
do you know how I can get a random number in the specified range?
like what this shell command does:
$ shuf -i 10000-99999 -n 1
19869Thank you in advance.
Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
(10000..99999).to_a.sample is one of several ways to do it.
On Sat, Oct 1, 2022 at 8:12 PM Veez Remsik <almighty@veez.us> wrote:
You can provide a range to the `rand` method.
eg. `rand 10000..99999`
On Sat, Oct 1, 2022 at 7:07 PM Henrik Pang <henrik@simplemail.co.in> > wrote:
do you know how I can get a random number in the specified range?
like what this shell command does:
$ shuf -i 10000-99999 -n 1
19869Thank you in advance.
Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
--
Andy Maleh
LinkedIn: Andy Maleh | LinkedIn
<https://www.linkedin.com/in/andymaleh>
Blog: http://andymaleh.blogspot.com
GitHub: AndyObtiva (Andy Maleh) · GitHub
Twitter: @AndyObtiva <https://twitter.com/AndyObtiva>
Random.rand even chooses its output object class according to the Range type :
3.0.3 :003 > Random.rand(10.0..100)
=> 45.48188704112778
10..100 would have returned an Integer.
Best regards,
Le 02/10/2022 à 02:11, Veez Remsik a écrit :
You can provide a range to the `rand` method.
eg. `rand 10000..99999`
--
Lionel Bouton
gérant de JTEK SARL
https://www.linkedin.com/in/lionelbouton/
10000..99999 is a data stru in ruby? I never know this. thanks.
Veez Remsik wrote:
eg. `rand 10000..99999`
It is a range in Ruby. There is also a syntax like `10000...99999` with
three dots between. This excludes the latest number from the range. You can
also use the Range class beside these syntactic sugars.
2 Eki 2022 Paz 03:21 tarihinde Henrik Pang <henrik@simplemail.co.in> şunu
yazdı:
10000..99999 is a data stru in ruby? I never know this. thanks.
Veez Remsik wrote:
> eg. `rand 10000..99999`Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>