I figured out how to generate random strings a certain amount of times per line. Now, I'm trying to figure out how to add a fixed, static string to the prefix of all the randomly generated strings.
for example, if this code spits out gCOABGSS
as a random string, I want to modify the script so it adds for example HEY-NOW
to each of the outputs, resulting in HEY-NOWgCOABGSS
def generate_code(number)
charset = Array('A'..'Z') + Array('a'..'z')
Array.new(number) { charset.sample }.join
end
5.times { puts generate_code(8) }
How to go about this?
Aucun commentaire:
Enregistrer un commentaire