Please help - Replace every array element by multiplication of previous and next

#1

I need to replace every element in an array by the multiplication pf the previous and the next element.

So far I got

def modif(array)
a = array
a[0] = array[0] * array[1]
l = array.length - 1
for i in (1…l)
a[i] = array[i-1] * array[i+1]
end

a[-1] = array[l] * array[-1]

a.reject(&:empty?)

puts "#{a}"

end

Where did I got it wrong?

#2

a = Array.new
or
a = []

These statements don’t seem necessary:

a[-1] = array[l] * array[-1]
a.reject(&:empty?)