Random output from array

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?
Why wouldn't My_Array.sample work?

I've always used it.
Yep, .sample works in 1.9.2 too. Are you getting any kind of error message? Maybe the problem lies somewhere else.
Ahhh I see I forgot to close my bracket LOL. I'm sorry for the trouble
If you don't want to use the sample way, you can always just do this:

ary = [*random values go here*]select = ary[rand(ary.size)]I never actually used the sample way, mostly because I had some extra conditions I needed to process before the randomization, but it could be useful for a simple randomization with no extra stuffs going on...Btw, why is this topic here? o.o
Btw, why is this topic here? o.o
Posted here on accident, it was approved, I reported it as soon as I realized but no one has reacted.

Original thread: https://forums.rpgmakerweb.com/threads/random-output-from-array.41078/