--000e0cd6a8e4deeaeb046d7ec4bd
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

On Mon, Jun 29, 2009 at 5:32 PM, Michael Kohl <citizen428 / gmail.com> wrote:

> 'Translating' your Pascal program I'd do something like this:
>

Oh yeah, you said you want to build a string:

def generate_string(len)
  raise ArgumentError if len < 1
  (1..len).map{ get_random_char }.join
end

generate_string(10) # "mjaxig1w35"

or

def generate_string(len)
  raise ArgumentError if len < 1
  s  '
  len.times { s << get_random_char }
  s
end

generate_string(10) # "dtuou833gq"

-- 
Il pinguino ha rubato il mio lanciafiamme.

Blog: http://citizen428.net/
Twitter: http://twitter.com/citizen428

--000e0cd6a8e4deeaeb046d7ec4bd--