We Recommend

Beginning Ruby: From Novice to Professional Beginning Ruby: From Novice to Professional
Beginning Ruby is a thoroughly contemporary guide for every type of reader wanting to learn Ruby, from novice programmers to web developers to Ruby newcomers. It starts by explaining the principles behind object-oriented programming and within a few chapters builds toward creating a genuine Ruby application.


Posted By

ishikawa on 07/09/06


Tagged

ruby text


Versions (?)


Random ASCII characters generator


Published in: Ruby 


This method generates random (and printable) ascii characters.

  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 

You need to login to post a comment.