+ 1

What's wrong

print "enter a number: " enter = gets.chomp() if enter > 5 puts "higher than five" else print "lower than five" end Why dont this work?

15th Aug 2018, 9:04 PM
Oskar Skogström
Oskar Skogström - avatar
4 Réponses
+ 2
alright, thanks!
15th Aug 2018, 9:23 PM
Just A Rather Ridiculously Long Username
+ 1
gets.chomp().to_i gets.chomp() defaults a string. by using .to_i it will take an integer instead, which can then be compared to 5
15th Aug 2018, 9:06 PM
LordHill
LordHill - avatar
+ 1
Could one of you mention what language this is?
15th Aug 2018, 9:11 PM
Just A Rather Ridiculously Long Username
+ 1
Ruby
15th Aug 2018, 9:12 PM
LordHill
LordHill - avatar