Hello,
After 2 months working with ruby i still bump to some of those:
what would be the simplest way (couldn’t find a rand method) to
achieve a subject’s task?
thanks!
t
Hello,
After 2 months working with ruby i still bump to some of those:
what would be the simplest way (couldn’t find a rand method) to
achieve a subject’s task?
thanks!
t
[email protected] wrote:
Hello,
After 2 months working with ruby i still bump to some of those:
what would be the simplest way (couldn’t find a rand method) to
achieve a subject’s task?thanks!
t
ary.sort_by { rand }
Regards
Stefan
[email protected] wrote:
Hello,
After 2 months working with ruby i still bump to some of those:
what would be the simplest way (couldn’t find a rand method) to
achieve a subject’s task?
If you mean that you want to shuffle the array, then:
array.sort_by{rand}
This comes up often enough that it’d almost be worth adding an
Array#shuffle (and/or #shuffle!) method to core…
On May 28, 2:07 pm, Alex Y. [email protected] wrote:
array.sort_by{rand}
This comes up often enough that it’d almost be worth adding an
Array#shuffle (and/or #shuffle!) method to core…–
Alex
Thanks Alex, that would be it!
best
t
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs