没有将Symbol隐式转换为Integer,Ruby [英] no implicit conversion of Symbol into Integer, Ruby
本文介绍了没有将Symbol隐式转换为Integer,Ruby的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是红宝石的新手,不知道如何解决此错误.当我运行包含以下代码的脚本时,总是会收到错误消息:没有将Symbol隐式转换为Integer.我认为问题出在@killProc ...,@ Name = ...和@working_directory中. 你能告诉我怎么了吗?
I am new to ruby, and have no idea, how to fix this error. when i run my script containing the code below, i always get the error: 'no implicit conversion of Symbol into Integer. I think the Problem is in the lines @killProc..., @Name=..., and @working_directory. Can you tell me whats wrong?
感谢您的帮助
class RubyCommand
include Patir::Command
attr_reader :cmd,:working_directory,:killProc
def initialize params,&block
@killProc=params[:killProc]
@name=params[:name]
@working_directory=params[working_directory]||"."
if block_given?
@cmd=block
else
raise "You Need to provide a block"
end
end
end
推荐答案
很确定您要传递数组而不是哈希.您应该这样称呼它:
Pretty sure you're passing an array instead of a hash. You should call it like this:
RubyCommand.new({killProc:1,name:"test"})
这篇关于没有将Symbol隐式转换为Integer,Ruby的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文