Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
#!/usr/local/bin/ruby class Array def randomize new_arr = [] until self.empty? x = self.choice new_arr << x self.delete x end return new_arr end def randomize! self.replace(self.randomize) end end arr = [2, 3, 5, 7, 11, 13, 17, 19] puts arr.join(", ") arr.randomize! puts arr.join(", ")
This paste will be private.
From the Design Piracy series on my blog: