From: Alexey Verkhovsky Date: 2004-07-18T07:12:18+09:00 Subject: [NUBY] Ruby Way code for shuffling an array doesn't behave as expected One example in The Ruby Way claims that in the following snippet second line shuffles the a (i.e., makes an array consisting of the same elements as a, but in a different order). a = [1, 2, 3, 4, 5] puts a.collect { a.slice!(rand(a.length)) }.inspect The claim sounds reasonable, but in reality Ruby 1.9 (CVS HEAD) always returns an array of three random elements, not of five as expected. Why is that so? Best regards, Alexey Verkhovsky