+ 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 Réponse
+ 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
Aujourd'hui en vedette
What?
0 Votes
HTML
0 Votes
Quiz duel
0 Votes
FRC Coding?
1 Votes
help
0 Votes
AI
2 Votes
APIs
1 Votes
Create Agent
0 Votes