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'
  2.  
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.