Created
February 12, 2013 15:53
-
-
Save yoshifumi0521/4770839 to your computer and use it in GitHub Desktop.
ランダムな文字列の作成方法。ruby。
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
chars = ("a".."z").to_a + ("A".."Z").to_a + (0..9).to_a | |
result = "" | |
8.times do | |
result << chars[rand(chars.length)] | |
end | |
result | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment