From: rickhg12hs Date: 2006-03-29T14:43:42+09:00 Subject: Re: How to interator over two arrays? Here are a couple hacks: def dotproduct(a,b) (0..a.length-1).inject(0) {|s,i| s + a[i]*b[i]} end or perhaps: require 'generator' def dotproduct(a,b) SyncEnumerator.new(a,b).inject(0) {|s,(i,j)| s+i*j} end There's no type checking here, etc. User beware. I've also found that using 'generator' can be pretty slow sometimes. I'll watch for better responses too.