Forum: Ruby on Rails Randomizing an Array

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
7277692cbdf58b87f9e1f5c5e367ae68?d=identicon&s=25 jwcooper (Guest)
on 2006-12-31 00:38
(Received via mailing list)
I'm trying to randomize an array, and this is what I have:

arr_set_unordered = randomizer(arr_set)

  def randomizer(arr)
   result = arr.collect { arr.slice!(rand arr.length) }

It does randomize it, but it only returns 3 values instead of the 5
values that I'm expecting.  Any ideas why?

Thank you!
This topic is locked and can not be replied to.