B
Boris Schmid
Hi all,
I wondered if there was a more compact method of generating things like
a random string, or a random list of numbers than I'm using now (using
ruby 1.9.0-1)
array = [] ; 100.times {array << rand}
string = "" ; 100.times {string << (rand(26) + 97).chr}
The temptation is to use
array = [rand] * 100
string = (rand(26) + 97).chr * 100
but that only draws one random number a 100 times.
Is there a bit of syntax that I missed?
I wondered if there was a more compact method of generating things like
a random string, or a random list of numbers than I'm using now (using
ruby 1.9.0-1)
array = [] ; 100.times {array << rand}
string = "" ; 100.times {string << (rand(26) + 97).chr}
The temptation is to use
array = [rand] * 100
string = (rand(26) + 97).chr * 100
but that only draws one random number a 100 times.
Is there a bit of syntax that I missed?