convert nils to zero

When an array is built up like this:

x = []
x[2] = 33
x[7] = 1

the values which haven't been explicitly set are nil and so bits of the method fails. This line just sets any nils to zero.