對於Ruby,我是一個真正的Newb,但我一直在使用代碼學院網站學習它。我要從我應該做的具體任務外引去,只讓我吃驚我鍵入下面的代碼時,得到了一個錯誤:Ruby控制流=(等於),如果
print "please type in an integer for x:"
x = gets.to_i
print "please type in an integer for y:"
y = gets.to_i
if "x" < "y"
puts "#{x} is less than #{y}"
elsif "x" > "y"
puts "#{x} is greater than #{y}"
else
puts "#{x} is equal to #{y}"
end
這是一個非常簡單的代碼,但最終的結果應該是要做到這一點:
"x" < "y" will report "x is less than y"
"x" > "y" will report "x is greater than y"
"x" = "y" will report "x is equal to y"
都較小和較大的工作,但是,如果X和Y是相同的,而不是僅僅報告「x是酒糟比Y」
我不知道,如果它不能計算這是Code Academy網站的錯誤,或者是我做錯了。任何幫助將不勝感激。如下
你不需要在if子句中引用變量名。 –