【问题标题】:'end' expected (to close 'while' at line 3) near '<eof>'预计在“<eof>”附近出现“结束”(在第 3 行关闭“同时”)
【发布时间】:2016-05-07 03:37:32
【问题描述】:

我对 Lua 完全陌生,我多次收到此错误“'end' 预期(在第 3 行关闭 'while')靠近 ''” 我已经检查过在线查找答案但没有运气所以我是希望有人能帮我解决这个问题,非常感谢

这是我的代码:

print ("Welcome to the maze")

while input ~= "leave" do

    print ("What do you want to do first? Leave or inspect?")


    input = io.read()

    if input == "inspect" then
        print (" You venture towards the maze.")
    end

    if input == "leave" then
        print ("You turn around and run.")
    end

【问题讨论】:

  • 尝试在 while 循环体的末尾添加一个 'end' 关键字
  • "" 表示“文件结束”。因此,该消息意味着您的代码在此之前满足所有语法规则。

标签: lua


【解决方案1】:

我从未见过 lua,但我认为阅读错误将是解决方案:

'end' 预期(在第 3 行关闭 'while')

所以我需要将end 输入代码:

print ("Welcome to the maze")

while input ~= "leave" do

    print ("What do you want to do first? Leave or inspect?")

    input = io.read()

    if input == "inspect" then
        print (" You venture towards the maze.")
    end

    if input == "leave" then
        print ("You turn around and run.")
    end

end

【讨论】:

  • 这真的是我需要做的吗?我花了大约 4 个小时搞乱代码......非常感谢 bud。我真的很感激。
  • 我希望只是这样,请给我反馈,否则我也可以在 lua 中尝试我;)
  • 没问题 - 如果你不介意,你可以将我的答案标记为解决方案 :)
  • 我该怎么做?我对这个网站也很陌生。
  • 啊,很高兴听到这个消息,如果我有一个新错误,我可以私信你吗?
猜你喜欢
  • 1970-01-01
  • 2019-07-22
  • 1970-01-01
  • 1970-01-01
  • 2014-06-03
  • 1970-01-01
  • 2016-06-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多