除了标题上的错误,我还得到:
C:/users/owner/documents/wyncode/unterminated string满足文件结尾。RB:20:语法错误,意外(arg,应为关键字“do”或“{”或“(”
puts(“僵尸在城堡里。。。
^
[用出口代码1在0.3s中完成]
另外,当我提示用户输入答案时,我的终端在继续之前不会要求我输入答案。
这是我的代码:
name.Capitalize = {"1" => "Mario",
"2" => "Luigi",
"3" => "Kirby",
}
puts "Zombie apocalypse"
puts "will you survive?"
def character (prompt, options)
puts = "who will you be?"
options = "Mario, Trump, Fox"
character = gets.chomp.downcase
until options.include? character
end
end
puts "ok #{name} all three of you run out of peach's castle which has been overrun"
if character = #{Mario} || #{Luigi} || #{kirby}
puts ("zombies are in the castle grounds, there are weapons over the bridge")
puts "What do you do, charge through or sneak?"
x = gets.chomp.downcase
if x == "sneak"
puts "oh you died"
if x == "charge through"
puts "the zombies tumbled over the bridge's edge, you made it safe and sound"
else
puts "you did nothing and were eaten alive by Princess Peach"
end
end
最佳答案
在第20行你用过:
puts ("zombies are in the castle grounds, there are weapons over the bridge")
它可以通过两种方式固定:
或者:
puts "zombies are in the castle grounds, there are weapons over the bridge"
或:
puts("zombies are in the castle grounds, there are weapons over the bridge")
即使这样,它也会帮助你摆脱那个特定的错误,还会有其他的错误一个接一个地冒出来为什么?因为,你的代码中有很多错误。
我钦佩你的热情。你在学习编程的第一周,你已经在开发动作冒险游戏的路上了,哇。可悲的是,再多的激情也帮不了你什么,除非你学会了基本的手艺。我建议你读一本关于鲁比的好书好好读一读,把概念弄清楚。
祝你好运。
关于ruby - 意外的tSTRING_BEG,期望keyword_do和用户提示不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30959851/