Looking at this block, I can follow the whole program until I hit, sum += square.
What is he point of this line, what does it say???
sum = 0
[1, 2, 3, 4].each do |value|
square = value * value
sum += square
end
puts sum
Looking at this block, I can follow the whole program until I hit, sum += square.
What is he point of this line, what does it say???
sum = 0
[1, 2, 3, 4].each do |value|
square = value * value
sum += square
end
puts sum
Big explination of 'compound operators' here.
http://stackoverflow.com/questions/2493140/meaning-of/2589389#2589389