Posted By

ishikawa on 07/09/06


ruby text

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


Random ASCII characters generator

 / Published in: Ruby

This method generates random (and printable) ascii characters.

  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  

You need to login to post a comment.