Why does this “gets” not work? If I place an integer in place of “gets” the program works fine. Curious! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why does this “gets” not work? If I place an integer in place of “gets” the program works fine. Curious!

https://code.sololearn.com/c1BOTWNry6lk/?ref=app

26th Apr 2018, 7:21 PM
Charles W Hsu
Charles W Hsu - avatar
2 Answers
+ 3
You might want to convert num to a number, not a string: num = gets.to_i
26th Apr 2018, 7:37 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 1
Ohhhhh! Thanks!
26th Apr 2018, 7:38 PM
Charles W Hsu
Charles W Hsu - avatar