ai didi

ruby-on-rails - 非常基本的 : "syntax error, unexpected ' =', expecting end-of-input"

转载 作者:太空宇宙 更新时间:2023-11-03 17:05:03 24 4
gpt4 key购买 nike

x = 2

打印“如果 2 + 2 = #{x + x},此应用程序运行正常”

这是我得到的错误信息

syntax error, unexpected '=', expecting end-of-input
print “This application is running okay if 2 + 2 = #{x + x}”
^

我在这里似乎找不到自己的错误。我在 OS X 10.10 上运行 Ruby 2.0.0,使用 TextEdit 编写代码。感谢帮助

最佳答案

代码是正确的。事实上,这是我机器上的输出。

2.1.5 :001 > x = 2
=> 2
2.1.5 :002 > print "This application is running okay if 2 + 2 = #{x + x}"
This application is running okay if 2 + 2 = 4 => nil

可能的解释是在代码中使用“花引号” 而不是标准引号 " 引起的语法错误。

print “This application is running okay if 2 + 2 = #{x + x}”

这是一个特殊字符,不会被解释为字符串开启符,并可能导致您的脚本失败。

关于ruby-on-rails - 非常基本的 : "syntax error, unexpected ' =', expecting end-of-input",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28435106/

24 4 0
文章推荐: git - 将 git repo 从一台机器克隆到另一台机器
文章推荐: python 重复正则表达式
文章推荐: c# - MVC 5 本地化工作在 localhost 但不是服务器
文章推荐: python - crypt.crypt 在 ubuntu 和 fedora 上的不同结果
太空宇宙
个人简介

我是一名优秀的程序员,十分优秀!

滴滴打车优惠券免费领取
滴滴打车优惠券
全站热门文章
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com