Created
July 26, 2008 02:53
-
-
Save ishikawa/2582 to your computer and use it in GitHub Desktop.
Random ASCII Characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'enumerator' | |
def random_string(length=10, s="") | |
length.enum_for(:times).inject(s) do |result, index| | |
s << rand(93) + 33 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment