Hi --

On Wed, 27 Nov 2002, ahoward wrote:

> On Wed, 27 Nov 2002, Gordon Miller wrote:
>
>
> [snip]
> G> c = z.collect_with_index { |el, i| f(el, a[i], b[i]) }
> [snip]
>
>
>   c = collect %w(0 1 2), %w(zero one two) do |a, b|
> 	[a,b]
>       end
>
>   p c				>> [["0", "zero"], ["1", "one"], ["2", "two"]]
>
>
>   c = collect_with_index %w(0 1 2), %w(zero one two) do |idx, a, b|
> 	[idx, a,b]
>       end
>
>   p c				>> [[0, "0", "zero"], [1, "1", "one"], [2, "2", "two"]]
>
>
> imho, this syntax is cleaner.

It could get unclean in a hurry, though :-)

  class Thing < Array
    def meth(other)
      a = collect { |e| do_something_with(e) }
      b = collect_with_index(self,other)...      # ugh
      ...
    end
  end


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav