Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array within arrays or Hash within array.. etc

Status
Not open for further replies.

Dubealex

Programmer
Feb 13, 2005
2
CA
Hi, I'm wondering if it's possible to implement an array inside another array, or hash, and be able to access an element of the sub array (without making attribute and objects.)

Like this:

my_array[0]=[1,2,3,4]

and be able to, for example, access the array ID# 1 of the sub array [1,2,3,4] which should be 2.

Of course, my_arrau[0[1]] do not work.. I tried many things, still dont work.

I was just wondering if it was possible a way or another.

(note: I want to make multiple list of string, and be able to access the list I want, and then the string I want on that list, without making a single variable per string...)
 
Code:
a=[]
a[0]=[3,5,7]
a[1]=[4,6,8]
p a
puts a[0][1]
produces
[tt]
[[3, 5, 7], [4, 6, 8]]
5
[/tt]
 
Thanks, this is exactly what I was looking for !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top