On 12 Nov 2002 at 2:19, TAKAHASHI Masayoshi wrote:

> (...)
> [ruby-dev:18651] Enumerable#zip
> 
>   Matz implemented Enumerable#zip method, but he has not
>   decide its behavior yet.
> 
>   Enumerable#zip is a method to mix some sequences(Array or
>   Object which has to_ary method). But, when length of
>   sequences are not same, the behavior is not clear.
> 
>     a = [1,2,3,4]
>     b = [2,4]
>     a.zip(b) #=> ?
> 
>    a.) a.zip(b) #=> [[1,2],[2,4],[3,nil],[4,nil]]
> 
>    b.) a.zip(b) #=> [[1,2],[2,4]]
> 
>    c.) a.zip(b) #=> [[1,2],[2,4],[3,nil],[4,nil]]
>        b.zip(a) #=> [[2,1],[4,2]]
> 
>    e.) a.zip(b) #=> raise Exception (ArgumentError(?))
> (...)


Maybe you could use something similar to the default value / block in 
Hash.new, something like

  a = [1,2,3,4]
  b = [2,4]

  a.zip(b)             #=> [[1,2],[2,4]]
  a.zip(b, nil)        #=> [[1,2],[2,4],[3,nil],[4,nil]]
  a.zip(b, "missing")  #=> [[1,2],[2,4],[3,"missing"],[4,"missing"]]

  d = 0
  a.zip(b) { d += 1 }  #=> [[1,2],[2,4],[3,1],[4,2]]

BTW, how is it implemented? Using threads / continuations / something 
else?

Regards,
Pit