a=["array1", "array2"] that stores the names of arrays as a string and
b=[["1","2"],["3","4"]] that has the values for each of these arrays.
I want to access individual arrays specifically and the contents of a
and b keep changing. So, I have to store it in a different array.
I want to create 2 new arrays array1 and array2 with values from b. Like
this.
If you could explain with a bit more detail what is the problem you
need to solve, maybe we can come up with better solutions.
Jesus.
···
On Tue, Jul 10, 2012 at 6:16 PM, Champak Ch <lists@ruby-forum.com> wrote:
I have 2 arrays.
a=["array1", "array2"] that stores the names of arrays as a string and
b=[["1","2"],["3","4"]] that has the values for each of these arrays.
I want to access individual arrays specifically and the contents of a
and b keep changing. So, I have to store it in a different array.
I want to create 2 new arrays array1 and array2 with values from b. Like
this.
Thank you for the quick response. I actually have the data as a hash.
But the hash keeps changing and I need to use the names and values
across multiple scripts. Thats the reason I need to save it elsewhere.
a=["array1", "array2"] that stores the names of arrays as a string and
b=[["1","2"],["3","4"]] that has the values for each of these arrays.
I want to access individual arrays specifically and the contents of a
and b keep changing. So, I have to store it in a different array.
I want to create 2 new arrays array1 and array2 with values from b.
Like this.
array1= ["1","2"]
array2= ["3","4"]
Can you please suggest some ideas?
-Champak
--
Sincerely yours,
Aleksey V. Zapparov A.K.A. ixti
FSF Member #7118
Mobile Phone: +34 677 990 688
Homepage: http://www.ixti.net
JID: zapparov@jabber.ru
But having separate global arrays for array1 and array2 will enable me
to access the data anywhere, even if the hash keeps changing.
What exactly keeps changing? What might a different version of myhash
look like? And what are the actual data behind this all?
To me myhash looks like a table with "array1" and "array2" being the
columns and the hashes being the rows. And now you want "snapshots" of
the columns at a certain point of time.
If that's the case, you should actually use a table object as a model
for the data. Internally you might store the data as a hash of the form
This would also allow you to easily access the columns.
I think having nested hashes or arrays is almost always a bad idea,
because they're hard to understand, hard to process and unsafe. It's
mostly better to have a specialized object, which encapsulates the data
and enforces a certain format.