gpt4 book ai didi

ruby - 简单Ruby程序中的错误

转载 作者:行者123 更新时间:2023-12-03 08:17:51 25 4
gpt4 key购买 nike

我在使用此代码时遇到了一些麻烦。当我运行它时,它告诉我:

unexpected $end, expecting }



这是代码:
puts "You have been contacted, and pooled into a secret orginization. Please select your mode."
puts "Double Agent"
puts "Spy"
Mode_Split = gets.chomp
# This is the turning point.
if Mode_Split = "Double Agent"
puts "Your job is to return data points from the FXR (Free Xutopian Republic) to the SU (Shared Union)."
Agency_Members = [["HEAD OF AGENCY", "Robin Woods" "AKA: Dexter"],["HIGHER UPS", "Bryan Silk", "AKA: Silk Road", "Voilet Blue", "AKA: Hydraog"],["AGENTS","Alex Cooper", "Matt Syon", "Jack Cumberland" "Mike Schmidt", "Frits Fitsgerald"],["SUSPECTED DOUBLE AGENTS", "Jack Cumberland"]]
Agency_Members.each { |X| puts Agency_Members }

最佳答案

有一些错误应该解决:

在回答您的问题时,您错过了“如果”的“结尾”
if <condition>
stuff in here
end

您还需要将大写字母“X”更改为小写。大写变量表示常量,因此大写字母“X”不能用作块索引。

Ruby约定将变量名使用小写/蛇形,因此Mode_SplitAgency_members应该分别为mode_splitagency_members

关于ruby - 简单Ruby程序中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29177489/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com