- 1

Quiz help

Can someone help me understand this problem. The solution was 5 and I just want a better understanding of how. x=0 for i in 2...4 x+=i end puts x

11th Jun 2021, 6:34 PM
Jeshua Pence
Jeshua Pence - avatar
3 Answers
+ 3
In this cycle, the range is set from 2 to 4, (4 is not inclusive), that is: 1. x = x + i => x = 0 + 2 2. x = 2 + 3
11th Jun 2021, 8:37 PM
Solo
Solo - avatar
+ 2
Ranges have inclusive and exclusive syntax .. includes the last number while ... does not hence 4 is not included in the loop.
14th Jun 2021, 11:25 AM
Gomolemo Matsunyane
+ 1
How did you get 4=x. Is it always going to be assumed to be the max?
11th Jun 2021, 7:21 PM
Jeshua Pence
Jeshua Pence - avatar