Random ASCII characters generator

/ Published in: Ruby
Save to your folder(s)

This method generates random (and printable) ascii characters.

Copy this code and paste it in your HTML
  1. require 'enumerator'
  3. def random_string(length=10, s="")
  4. length.enum_for(:times).inject(s) do |result, index|
  5. s << rand(93) + 33
  6. end
  7. end

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.