Skip to content

Instantly share code, notes, and snippets.

@thisivan
Created June 23, 2009 17:40
Show Gist options
  • Save thisivan/134703 to your computer and use it in GitHub Desktop.
Save thisivan/134703 to your computer and use it in GitHub Desktop.
Generate random strings in Ruby
# Random chars
chars = ('a'..'z').to_a + ('A'..'Z').to_a
(0...10).collect { chars[Kernel.rand(chars.length)] }.join
=> "nmhhuMrybz"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment