Ruby on Rails Tuesday, July 29, 2014

Hi,

Novice question:

I need to assign an item id to one of 3 arrays randomly but can't figure
out how to specify the correct array by combining "arr" and the randomly
generated number...

id = "100"
x = rand(1..3)

arr1 = Array.new
arr2 = Array.new
arr3 = Array.new

selected_array = "#{'arr' + x}" *** Not sure how to do this ****

selected_array.push(id)

Thanks in advance,

Dave Castellano

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/de5ac39b4cbb7999910529efee52c898%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment