Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Creating random code strings with Array#inject
# (to learn inject I am...)
# Using inject to create random strings
def code(size)
chars = ("a".."z").to_a+(0..9).to_a"") { |str, n| str += chars[rand(chars.size)].to_s }
50.times { |i| puts code(i) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment