I am running a Ruby script but getting the below error message.
我正在运行一个Ruby脚本,但是得到下面的错误消息。
root@li140-48:~/rbircd-master# ruby ircd.rb
ircd.rb:38:in `load': ircclient.rb:145: syntax error, unexpected tSTRING_BEG, expecting ':' (SyntaxError)
(value == true) ? key.upcase"#{key.upcase}=#{value}"
^
from ircd.rb:38:in `reload!'
from ircd.rb:41:in `<main>'
root@li140-48:~/rbircd-master#
Here is the code block around ircclient.rb:145
:
这是关于ircclient.rb:145的代码块:
def send_version(detailed=false)
if detailed
send_numeric 351, 'RubyIRCd0.1.0.', @server.name, 'FhiXeOoZE [Linux box 2.6.18-128.1.1.el5.028stab062.3 #1 SMP Sun May 10 18:54:51 MSD 2009 i686=2309]'
send @server.name, :notice, @nick, 'OpenSSL 0.9.8k 25 Mar 2009'
send @server.name, :notice, @nick, 'zlib 1.2.3'
send @server.name, :notice, @nick, 'libcurl/7.19.4 GnuTLS/2.6.6 zlib/1.2.3 c-ares/1.6.0 libssh2/0.18'
end
features = ServerConfig.features.clone
features.each_slice(13) do |slice|
slice.map! do |(key, value)|
(value == true) ? key.upcase"#{key.upcase}=#{value}"
end
slice << 'are supported by this server'
send_numeric '005', *slice
end
end
Please can someone help me?
请问有人能帮我吗?
1 个解决方案
#1
1
You're doing a ternary if but you're missing the else clause.
如果你错过了else子句,你就做了一个三进制。
Change
改变
(value == true) ? key.upcase"#{key.upcase}=#{value}"
to
来
value ? key.upcase : "#{key.upcase}=#{value}"
And then read How do I use the conditional operator in Ruby
然后读一下如何在Ruby中使用条件运算符。
#1
1
You're doing a ternary if but you're missing the else clause.
如果你错过了else子句,你就做了一个三进制。
Change
改变
(value == true) ? key.upcase"#{key.upcase}=#{value}"
to
来
value ? key.upcase : "#{key.upcase}=#{value}"
And then read How do I use the conditional operator in Ruby
然后读一下如何在Ruby中使用条件运算符。