[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Jumping to "the next one" in something#each

Nicolas Desprès

2/10/2007 11:04:00 AM



On Feb 9, 11:43 pm, "Garance A Drosehn" <dros...@gmail.com> wrote:
> I'm sorry that this message will be long and somewhat rambling,
> but I wanted to try to write up my thoughts on this, even though
> my thoughts are not very clear...
>
> There's a situation that I occassionally run into, which I can work
> around easy enough, but it seems that there might be an cleaner
> solution than the ones I fall back on. Let's say I want to have
> something like:
>
> ARGV.each { |arg|
> case arg
> when "-f"
> ...do something with the *next* value of |arg|...
> end
>
> }
>

ARGV.each_with_index { |arg, index|
case arg
when "-f"
... do something with ARGV[index + 1]...
end
}

Cheers,

Nico