+ 15

[ Solved ] Why code output is 33?

Practicing what I learned with Ruby challenges. Have no idea why the code output is - 33? Below is the screenshot of challenge: https://www.sololearn.com/post/593067/?ref=app

19th Sep 2020, 6:12 AM
Shivani 📚✍
Shivani 📚✍ - avatar
2 Antworten
+ 6
a = 0 for i in (10..12) a+=i end =begin 10.times do at+=1 =end puts a for i in (10..12) this for loop gives 10, 11, 12 a+=i this line adds (a=10+11+12) and hence equals to 33. anything between =begin . . . =end are comments.
19th Sep 2020, 7:08 AM
minirkk
minirkk - avatar
+ 6
Thanks RKK ! I understood it later while learning from tutorial the difference between ".." 2 dots and 3 dots "..." with the given value 😅
22nd Sep 2020, 3:50 PM
Shivani 📚✍
Shivani 📚✍ - avatar