Skip to content

Instantly share code, notes, and snippets.

@arya
Created January 8, 2009 19:58
Show Gist options
  • Save arya/44856 to your computer and use it in GitHub Desktop.
Save arya/44856 to your computer and use it in GitHub Desktop.
# original
def randomized
order = self.dup
result = []
result << order.choice! until order.blank?
result
end
# new
def randomized(n = nil)
order = self.dup
result = []
result << order.choice! until order.blank? || n <= result.size
result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment