Re: increasing counter whithin loop?


#1

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


#2

On Mon, 05 Dec 2005 15:13:46 +0100, Kroeger, Simon (ext)
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