输入的条件不匹配[重复]

问题描述

                                                                                                                  这个问题已经在这里有了答案:                                                      

解决方法

        
gets
还返回换行符和回车符\“ \\ r \\ n \”,例如\“再见\\ r \\ n \”。这意味着您必须先将它们删除,然后再与其他字符串进行比较。 (请参阅String.strip)
while [gets,gets,gets].map(&:strip) != [\'BYE\',\'BYE\',\'BYE\']
  puts \'Grandma: ...\'
end

puts \'Grandma: \' + \'Fine,sonny,don\\\'t hang out with your aging grandmother!\'.upcase
    ,        gets的输入包括换行符(BYE \\ n)。做gets.chomp摆脱它。     ,        我不太确定,但也许您正在尝试执行以下操作:
bye_3 = Array.new(3,\"BYE\")
until Array.new(3){gets.chomp} == bye_3
  puts \"Grandma: ...\"
end
puts \'Grandma: \' + \'Fine,don\\\'t hang out with your aging grandmother!\'.upcase
Array.new(3,\"BYE\")
[\"BYE\",\"BYE\",\"BYE\"]
相同,
Array.new(3){gets.chomp}
[gets.chomp,gets.chomp,gets.chomp]
相同。     

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...