M
Mk 27
Is there some equivalent to file.lineno when using array.each? Eg, if I
am iterating thru an array of strings searching for a pattern, and I
want to save the current array index, do I have to do this:
count = 0
array.each { |e|
finds.push count if e =~ /pattern/
count += 1
}
or is there a "array.currentindex"? I guess I could use each_index...
am iterating thru an array of strings searching for a pattern, and I
want to save the current array index, do I have to do this:
count = 0
array.each { |e|
finds.push count if e =~ /pattern/
count += 1
}
or is there a "array.currentindex"? I guess I could use each_index...