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]


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.