As the title says… if I have an array containing subarrays is it possible to split the array and rename the new split arrays? I know I could simply type new_array=array[0] and so on but the problem is that the original array containing the sub arrays will vary in size.
original array…
array=[["a", "1", "2", "3"], ["b", "1", "2", "3"], ["c", "1", "2", "3"]...]
split and renamed arrays…
array1=["a", "1", "2", "3"]
array2=["b", "1", "2", "3"]
array3=["c", "1", "2", "3"]...
I hope that makes sense… thanks
Frank
The only way I see to do quite literally what you are looking for is:
But of course, this is very ugly. Unless you absolutely need to do this, you should find a way to use your array without converting it to a list of variables. You shouldn’t normally need to convert it to a hash, either – that’s just converting one indexing style to another indexing style, and isn’t giving you any added functionality.
Interestingly, note that this will not work, because eval (and the each block) have their own scope, which is not shared with the top-level scope: