我使用以下代码来比较字符串,但它总是把我带到其他地方.为什么?
print("Enter your state abbreviation: ") state_abbreviation = gets if state_abbreviation.upcase == "NC" puts("North Carolina") elsif state_abbreviation.upcase == "SC" puts("Sourth Carolina") elsif state_abbreviation.upcase == "GA" puts("Georgia") elsif state_abbreviation.upcase == "FL" puts("Florida") elsif state_abbreviation.upcase == "AL" puts("Alabama") else puts("You have enter wrong abbreviation") end
我也试过.eql?(“string”),但我得到了相同的结果.