I'm currently generating an 8-character pseudo-random uppercase string for "A" .. "Z":
(我目前正在为“ A” ..“ Z”生成一个8个字符的伪随机大写字符串:)
value = ""; 8.times{value << (65 + rand(25)).chr}
but it doesn't look clean, and it can't be passed as an argument since it isn't a single statement.
(但它看起来并不干净,并且由于它不是单个语句,因此不能作为参数传递。)
To get a mixed-case string "a" .. "z" plus "A" .. "Z", I changed it to: (为了获得大小写混合的字符串“ a” ..“ z”加上“ A” ..“ Z”,我将其更改为:)
value = ""; 8.times{value << ((rand(2)==1?65:97) + rand(25)).chr}
but it looks like trash.
(但看起来像垃圾)
Does anyone have a better method?
(有谁有更好的方法?)
ask by community wiki translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…