+ 5

Can somebody tell me how to store user input into a variable so you can do anything with it for example math???

14th Mar 2017, 10:39 PM
Shedrick Williams
Shedrick Williams - avatar
2 Antworten
+ 10
Use this for strings: name = gets # or use name =gets.chomp gets on it's own returns a \n character, and chomp removes it. When dealing with integers strictly use: digits = gets.to_i That will convert the users string into an integer.
14th Mar 2017, 11:00 PM
Mark Foxx
Mark Foxx - avatar
+ 2
ok thank you
15th Mar 2017, 3:07 AM
Shedrick Williams
Shedrick Williams - avatar