On 2014-Jul-30, at 10:59 , Eric Saupe ericsa...@gmail.com wrote:
To expand on what Scott is saying here is some code that gives an example of
what he is referring to.
id = 100
x = rand(1..3)
arrays = [Array.new, Array.new, Array.new]
selected_array = arrays[x]
selected_array.push(id)
I knew there would be a nice simpler Ruby way. I love the second solution,
Rob. Below is the updated example.
id = 100
arrays = [Array.new, Array.new, Array.new]
arrays.sample.push(id)
On Thursday, July 31, 2014 8:45:33 AM UTC-6, Rob Biedenharn wrote:
On 2014-Jul-30, at 10:59 , Eric Saupe
On Jul 31, 2014, at 10:00 AM, Eric Saupe ericsa...@gmail.com wrote:
I knew there would be a nice simpler Ruby way. I love the second solution,
Rob. Below is the updated example.
One tiny note, this is purely a matter of style taste, spelling it out vs
concision, but I thought it might be
You can simplify the arrays construction, too: (with slight reformatting of the
arrays output)
irb2.1.1 arrays = Array.new(3) { Array.new }
#2.1.1 = [[], [], []]
irb2.1.1 100.times {|id| arrays.sample.push(id) }
#2.1.1 = 100
irb2.1.1 arrays
#2.1.1 = [[0, 2, 6, 8, 9, 11, 14, 16, 17, 18, 22,
To expand on what Scott is saying here is some code that gives an example
of what he is referring to.
id = 100
x = rand(1..3)
arrays = [Array.new, Array.new, Array.new]
selected_array = arrays[x]
selected_array.push(id)
On Tuesday, July 29, 2014 8:05:16 PM UTC-6, Scott Ribe wrote:
On Jul
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}
On Jul 29, 2014, at 7:33 PM, Dave Castellano li...@ruby-forum.com wrote:
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 =
7 matches
Mail list logo