support lambdas in threads

@amw does this look good ?
I'll try processes next ...


thx, much better now :)


On Thu, Aug 21, 2014 at 6:02 AM, Adam Wróbel <notifications@github.com>
wrote:

> In lib/parallel.rb:
>
> > +    def each_with_index(&block)
> > +      if producer?
> > +        index = 0
> > +        loop do
> > +          item = next!
> > +          break if item == Parallel::StopIteration
> > +          yield(item, index)
> > +        end
> > +      else
> > +        @items.each_with_index(&block)
> > +      end
> > +    end
> > +
> > +    def [](index)
> > +      if producer?
> > +        next!
>
> This is very confusing and potentially dangerous. You are ignoring the
> value of requested index and simply returning the next value. A surprising
> class behavior is always bad design even if you're now using the class in a
> way that does not cause problems.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/grosser/parallel/pull/107/files#r16536971>.
>