puts "Enter the first number"
num1 = Float(gets)
puts "Enter the second number"
num2 = Float(gets)
puts "Enter the operation"
op = gets
op = op.chomp # <--- THIS LINE!
case op
when "+" then puts num1 + num2
when "-" then puts num1 - num2
when "*" then puts num1 * num2
when "/" then puts num1 / num2
end
答案 0 :(得分:8)
进入&#34; +&#34;操作,你点击两个键, + 和返回。两者都产生一个字符,产生"+\n"
。 (\n
是换行符)
chomp
删除换行符。