[英]Trying to do a bundle fails with “There was a SyntaxError while loading arel.gemspec”
This is the error I get when I do a bundle in the rails repo in the master branch. 这是我在master分支的rails repo中进行捆绑时得到的错误。
There was a SyntaxError while loading arel.gemspec:
/home/apnabhzu/ruby/gems/bundler/gems/arel-3c429c5d86e9/lib/arel/table.rb:14: syntax
error, unexpected tLABEL
def initialize(name, as: nil, type_caster: nil)
^
/home/apnabhzu/ruby/gems/bundler/gems/arel-3c429c5d86e9/lib/arel/table.rb:14: Can't
assign to nil
def initialize(name, as: nil, type_caster: nil)
^
/home/apnabhzu/ruby/gems/bundler/gems/arel-3c429c5d86e9/lib/arel/table.rb:125: syntax
error, unexpected keyword_end, expecting $end from
/home/apnabhzu/ruby/gems/bundler/gems/arel-3c429c5d86e9/arel.gemspec:3:in `<main>'
I have listed the environment details below : 我在下面列出了环境详细信息:
I have no idea why I am getting this, what could be a possible fix? 我不知道为什么要得到这个,可能有什么解决办法?
Why you are trying to assign nil
value to parameter? 为什么要尝试将
nil
值分配给参数?
The default parameter is used when the parameter isn't provided. 未提供参数时使用默认参数。
If you provide it as nil, then it will be nil. 如果您将其提供为nil,那么它将为nil。
If you want to set a default value, even if nil is passed, and still allow calling the method without an argument you need to set the default value to nil and use the "or equals" operator: 如果要设置默认值,即使已传递nil,并且仍允许在不带参数的情况下调用该方法,则需要将默认值设置为nil并使用“或等于”运算符:
def initialize(name,as=nil)
as ||= "Your value"
puts as
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.