Paul Carvalho wrote:
> I had to give my loop a 'memory'. Here's what I ended up doing:
> ----
> first_seen = true
> array.each_index do | position |
> ...
> if array[ position ] == 'bar' and first_seen
> start_col = 30
> first_seen = false
> elsif array[ position ] == 'bar' and ! first_seen
> start_col = 40
> end
> ...
> end
> ----
>
> This works in this example because there are at most only two
> occurrences of 'bar' in the array.
This will do the same thing, somewhat more simply.
first_seen = true
array.each do |element|
...
if element == 'bar'
if first_seen
start_col = 30
first_seen = false
else
start_col = 40
end
end
...
end
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general