Kyle X. wrote in post #990090: > Hello, this is not so much a sketchup question as a Ruby one that I > cannot figure out. What I am trying to do is create new variables that > all have the same base name then add a number to make a series of > variables named like wall1, wall2, wall3, ect. > That is a typical beginner question. You NEVER need to do that. All computer languages have arrays for that purpose. > What I am trying to do is take an array, lets call it originalarray, > which has say 64 objects in it, and create 8 smaller arrays from this. > So array1 would be orginalarray[0-7], array2 would be > originalarray[8-15], and so on for 8 new arrays. The problem is I do not > know the length of the original array, as it is being populated by data > from an xml sheet, but I know the multiple of how it is being created, > ie by multiples of 8. > > I have been trying to do this using loops doing something like: > > n=0 > while n != originalarray.length/8 > n=n.to_s > array+n=originalarray[0..7] > n=n.to_i > n=n+1 > end > > > > I realize that is doesn't work at all in that you cannot make variables > like this, I am just trying to give a better picture of what my goal is. > So I am wondering is it possible to accomplish this at all, and if so > how? Using arrays. An array can contain anything--including other arrays: require 'enumerator' #not necessary in ruby 1.9 master_arr = [] data = [1, 2, 3, 4, 5, 6, 7, 8] data.each_slice(3) do |sub_arr| master_arr << sub_arr end p master_arr --output:-- [[1, 2, 3], [4, 5, 6], [7, 8]] -- Posted via http://www.ruby-forum.com/.