Jeff Schwab
8/20/2006 2:55:00 PM
Andy Black wrote:
> I need to create a different array each time that I am going through a
> loop. I wonder how I can assign different names to the arrays based
> on the iteration count. For example first time that I go through the
> loop I want to create an array named: a1, second one, a2 and so on.
How about a[0], a[1], etc.?
text = <<SAMPLE_TEXT
Now is the time
for all good men
to come to the aid
of their party.
SAMPLE_TEXT
a = []
text.each {|line|
words = line.split
a << words
}
p a[3] # ["of", "their", "party"]
p a[0] # ["Now", "is", "the", "time"]