[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-core
Subject:    [ruby-core:33636] Re: Why is SyncEnumerator in REXML?
From:       Manfred Stienstra <manfred () fngtps ! com>
Date:       2010-12-08 8:26:07
Message-ID: 05928B40-4032-4B94-AEFD-7F52CEE16279 () fngtps ! com
[Download RAW message or body]

On Dec 7, 2010, at 11:25 PM, James Edward Gray II wrote:

> On Dec 7, 2010, at 3:41 PM, Asher wrote:
> 
> > Would your preference be to direct them to manually iterate each of the \
> > enumerators or create their own convenience class? Seems easy enough, but given \
> > that SyncEnumerator is there it made sense to me to leave it and move it into the \
> > main extension branch.

Alternatively you can use each_with_index on the first object and use the index on \
the others.

left  = 1..3
right = %w(a b c)

def iterate(left, right)
  left.each_with_index do |item, index|
    yield [item, right[index]]
  end
end

iterate(left, right) do |l, r|
  p [l, r]
end


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic