/ Published in: Ruby

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
class Array def shuffle n = [] while !empty? n << delete_at(rand(size)) end n end end # Usage >> [1,2,3,4,5].shuffle => [2, 4, 5, 1, 3]
URL: http://concentrationstudios.com/2006/12/20/12-days-of-stupid-ruby-tricks
Comments
