0
Why doesn't this code work?
x=gets puts x+10 I try to type in a number to add to 10 and it returns an error edit: oh I see thank you guys. What is the purpose of having strings separate in the first place?
3 Réponses
+ 3
because the input you get with "gets" is a string even if it is a number. you need to convert your string to an integer
x = gets.to_i
puts x+10
+ 8
The variable x is a string data type by default try this, this will surely work:
x = gets.to_i
puts x+10
+ 2
xD