# Re: increasing counter whithin loop?

**URL:** <https://www.ruby-forum.com/t/re-increasing-counter-whithin-loop/95242>\
**Category:** Ruby\
**Created:** [December 5, 2005, 3:18pm UTC](https://www.ruby-forum.com/t/re-increasing-counter-whithin-loop/95242 "2005-12-05T15:18:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![simon.kroeger.ext](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@simon.kroeger.ext](https://www.ruby-forum.com/u/simon.kroeger.ext)\
**Post date:** [December 5, 2005, 3:18pm UTC](https://www.ruby-forum.com/t/re-increasing-counter-whithin-loop/95242/1 "2005-12-05T15:18:03Z")

</div>

perhaps:

a.inject(false) do |skip, elt|  
puts elt if !skip  
elt==“b”  
end

(no, I don’t think this is realy nice)

cheers

Simon

---

<div class="post-metadata">

**Author:** ![simon.kroeger.ext](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@simon.kroeger.ext](https://www.ruby-forum.com/u/simon.kroeger.ext)\
**Post date:** [December 6, 2005, 4:25am UTC](https://www.ruby-forum.com/t/re-increasing-counter-whithin-loop/95242/2 "2005-12-06T04:25:45Z")

</div>

On Mon, 05 Dec 2005 15:13:46 +0100, Kroeger, Simon (ext)  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> (no, I don’t think this is realy nice)

Here is another (not really nice) way to do it, using the flip-flop  
operator:

> > %w( a b c d b e ).each { |el| nil if (puts(el) || el == “b”)…true }  
> > a  
> > b  
> > d  
> > b

Dominik
