From: Jason Lillywhite Date: 2008-06-12T08:06:01+09:00 Subject: subtracting arrays I suspect there is a cleaner way to do this with inject or collect. a = [1,2,3] b = [1,1,1] c = [] i = 0 while i < 3 do c << a[i] - b[i] i += 1 end p c => [0, 1, 2] I tried a collect but can't figure out how to get variables from outside the block to work inside the block. I was thinking something like c = [] c.collect {|a,b| a - b} but that is not it. -- Posted via http://www.ruby-forum.com/.