Randy Kramer
3/27/2005 10:15:00 PM
I've written a quick and dirty regular expression tester, but there's one
thing I'd like to try to clean up.
At the moment, to display all the groups, I have a series of print statements
like:
print $1.to_s + "\n"
print $2.to_s + "\n"
...
print $9.to_s + "\n"
Surely there's a more Ruby'esque way, but I haven't found it so far. I'd like
to create a loop, or a range, or something and then iterate over it. Here
are snippets of some of the things I've tried, but I don't seem to be making
any progress (and I'm shooting in the dark):
eval($#{i})
eval $#{i}
[1..9].each {|i| print $i.to_s + "\n"}
[1..9].each {|i| print $#{i}.to_s + "\n"}
Is there a way to increment from $1 through $9 in some kind of loop?
Thanks!
Randy Kramer
(I know I'll feel dumb when somebody points out how simple it is, but ...)