Skip to content

Instantly share code, notes, and snippets.

@beepony
Created May 26, 2016 03:09
Show Gist options
  • Save beepony/67f9dafa85d9283e11056cc93b8d4153 to your computer and use it in GitHub Desktop.
Save beepony/67f9dafa85d9283e11056cc93b8d4153 to your computer and use it in GitHub Desktop.
#! /usr/bin/ruby
# 随机生成 7 位数字的
string = ('a'..'z').to_a.shuffle[0..7].join
@beepony
Copy link
Author

beepony commented May 27, 2016

优雅的方式生成 10 位大小写和数字随机数

[*'0'..'9', *'a'..'z', *'A'..'Z'].sample(10).join

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment