+ 1

What is the output of this code?

def x(y) res = 0 (0..y).each {|z| res+=z} res end puts x(3)

18th Apr 2018, 3:42 PM
MEDSON NAFTALI KIULA
MEDSON NAFTALI KIULA - avatar
5 Answers
+ 7
You can check the output by yourself. Run this code in code playground. - Tap on { } icon at top bar - Tap on + floating button - Select ruby - Paste your code and hit run 🏃
18th Apr 2018, 4:10 PM
Shamima Yasmin
Shamima Yasmin - avatar
+ 1
6
2nd Jan 2019, 7:39 PM
Claire
Claire  - avatar
- 1
What is the output of this code? def x(y) res = 0 (0..y).each {|z| res+=z} res end puts x(3)
30th Dec 2018, 4:19 PM
الاستاذ الليبي
الاستاذ الليبي - avatar
- 1
What is the output of this code? def x(y) res = 0 (0..y).each {|z| res+=z} res end puts x(3)
30th Dec 2018, 4:20 PM
الاستاذ الليبي
الاستاذ الليبي - avatar
- 1
😔😔😔
30th Dec 2018, 4:20 PM
الاستاذ الليبي
الاستاذ الليبي - avatar