+ 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

13th Dec 2018, 2:50 AM
Adrian Eranzi
Adrian Eranzi - avatar
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
13th Dec 2018, 5:08 AM
Diego
Diego - avatar