Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #1997
| From | "Kyle X." <haebooty@yahoo.com> |
|---|---|
| Newsgroups | comp.lang.ruby |
| Subject | How can I generate new variables? |
| Date | 2011-03-30 19:42 -0500 |
| Organization | Service de news de lacave.net |
| Message-ID | <33ba41ea1d06d357f353d2462a951026@ruby-forum.com> (permalink) |
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.
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? Or is there a much easier way to do this using classes or some
other method to accomplish the same goal?
Any help would be greatly appreciated. Thank you in advance for your
time.
--
Posted via http://www.ruby-forum.com/.
Back to comp.lang.ruby | Previous | Next — Next in thread | Find similar | Unroll thread
How can I generate new variables? "Kyle X." <haebooty@yahoo.com> - 2011-03-30 19:42 -0500
Re: How can I generate new variables? 7stud -- <bbxx789_05ss@yahoo.com> - 2011-03-30 20:14 -0500
Re: How can I generate new variables? "Kyle X." <haebooty@yahoo.com> - 2011-03-30 22:08 -0500
Re: How can I generate new variables? Gunther Diemant <g.diemant@gmx.net> - 2011-03-31 03:08 -0500
Re: How can I generate new variables? "Kyle X." <haebooty@yahoo.com> - 2011-03-31 14:30 -0500
Re: How can I generate new variables? Robert Klemme <shortcutter@googlemail.com> - 2011-03-31 03:11 -0500
Re: How can I generate new variables? 7stud -- <bbxx789_05ss@yahoo.com> - 2011-03-31 20:06 -0500
Re: How can I generate new variables? "Kyle X." <haebooty@yahoo.com> - 2011-04-02 01:18 -0500
Re: How can I generate new variables? Robert Klemme <shortcutter@googlemail.com> - 2011-04-04 02:15 -0500
csiph-web