concentration studios 12 Days of Stupid Ruby Tricks


/ Published in: Ruby
Save to your folder(s)



Copy this code and paste it in your HTML
  1. 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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.