Martin Kahlert <martin.kahlert / infineon.com> writes:

> I want to do something like that:
> 
> a = Array.new(1000000, 1)
> b = Array.new(1000000, 2)
> c = Array.new(1000000)
> 
> for i in 0 ... a.length
>    c[i] = a[i] + b[i] 
> end

This is a silly answer, but depending on the usage patterns, you might
also want to look at

  @a = ...
  @b = ...

  c = Array.new
  def c.[](n)
    @a[n] + @b[n]
  end

This would be a win if the accessed only a subset of the result (and
if all accesses go through []).


Dave