On Aug 15, 2007, at 11:36 AM, Haze Noc wrote:

> Does anyone have any good ways of transferring a string to random  
> chars?
> For example, our string is hello, and i want HeLlO or something.. Is
> there an easy way of doing this without splitting the string and  
> reading
> each value of an array?

A solution based on gsub:

   "foobar".gsub(/./) do |c|
     c.send([:downcase, :upcase][rand(2)])
   end

In this case it does not matter the dot does not match newlines, we  
will ignore them, if any, and go on with the rest of the string.

-- fxn