0
Ruby languange - Question about CASE and gets
If I run: a = 2 case a when 1 puts "One" when 2 puts "Two" when 3 puts "Three" end My output is : Two But if I run a = gets case a when 1 puts "One" when 2 puts "Two" when 3 puts "Three" end and fill out 2 as an input, my output is: No output.
3 Answers
+ 3
In Ruby, gets will take input as a string. So you know why the above code gives no output.
To convert your input to an integer, write instead
x=gets.to_i
+ 2
Most welcome! :)
0
Perfect! Thanks a lot!