Skip to content

Instantly share code, notes, and snippets.

@yoshifumi0521
Created February 12, 2013 15:53
Show Gist options
  • Save yoshifumi0521/4770839 to your computer and use it in GitHub Desktop.
Save yoshifumi0521/4770839 to your computer and use it in GitHub Desktop.
ランダムな文字列の作成方法。ruby。
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