lets say I have this array:
My_Array = ["foo", "bar"]I know in Ruby 1.9.3 you could just do
My_String = My_Array.samplebut I don't think it works in this case
I could just set it up with variables like
num = rand(100)if num < 50 My_String = "foo"endbut that would be too tedious because I want to create a long array.
So how would I go about getting a random out put from an array?
My_Array = ["foo", "bar"]I know in Ruby 1.9.3 you could just do
My_String = My_Array.samplebut I don't think it works in this case
I could just set it up with variables like
num = rand(100)if num < 50 My_String = "foo"endbut that would be too tedious because I want to create a long array.
So how would I go about getting a random out put from an array?
Last edited by a moderator:

