我正在与朋友一起练习练习14,这是一些非常简单的字符串插值和用户输入抓取。我的代码如下所示:
if (revision == null)
{
assessment = _hazardAssessmentService.CustomQuery().Where(x => x.LaboratoryId == selectedLab.Id).OrderByDescending(x => x.Revision).FirstOrDefault();
}
else
{
int rev = (int) revision;
assessment = _hazardAssessmentService.CustomQuery().FirstOrDefault(x => x.LaboratoryId == selectedLab.Id && x.Revision == rev);
}
应该很简单,但我发现在user_name = ARGV.first
prompt = '> '
puts "Hi #{user_name}."
puts "I'd like to ask you a few questions."
puts "Do you like me #{user_name}? ", prompt
likes = $stdin.gets.chomp
puts = "Where do you live #{user_name}? ", prompt
lives = $stdin.gets.chomp
puts "What kind of computer do you have? ", prompt
computer = $stdin.gets.chomp
puts """
Alright, so you said #{likes} about liking me.
You live in #{lives}. Not sure where that is.
And you have a #{computer} computer. Nice.
"""
行之后,屏幕上没有显示提示“你住在哪里”的下一行,likes=
提示输入。也就是说,在进入“喜欢”后立即跳转到“行”提示,而不显示之前的提示输出!从lives=
开始的下一个提示按预期工作。
我正在使用ruby 2.1.2,但2.2.3上出现了相同的行为,并且在线REPL here
为什么会这样?
答案 0 :(得分:2)
在第8行上有一个 = 。删除它应该可以解决问题。