+ 6
How this "for" loop is executed?
Can someone explain what this does, step by step? x = 0 for i in 2...4 x+=i end puts x
1 Resposta
+ 7
"For” loop from 2 to 3, therefore running two times.
# x=0
First loop: # i=2
x += 2 # x=2
Second loop: # i=3
x += 3 # x=5
puts x #x=5