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.
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.