Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby程序ARGV错误_Ruby_Rubygems - Fatal编程技术网

Ruby程序ARGV错误

Ruby程序ARGV错误,ruby,rubygems,Ruby,Rubygems,我有一个Ruby程序: k = ARGV[0] j = ARGV[1] def random_tuple(length) letters_and_numbers = "0123456789" answer = "" length.times { |i| answer << letters_and_numbers[rand(10)] } answer end j.times { |i| Product.create number:random_tuple(8) }

我有一个Ruby程序:

k = ARGV[0]
j = ARGV[1]

def random_tuple(length)
  letters_and_numbers = "0123456789"
  answer = ""
  length.times { |i| answer << letters_and_numbers[rand(10)] }
  answer
end

j.times { |i|  Product.create number:random_tuple(8) }
k=ARGV[0]
j=ARGV[1]
def随机_元组(长度)
字母和数字=“0123456789”
答案=”“

length.times{| i | answer几天前,我的一个脚本中出现了相同的错误。你必须将ARGV[1]转换为整数才能与times方法一起使用。使用j.to|i,它就会工作。

我需要看看
产品的外观如何?包括你在问题中遇到的错误,不要指望我们运行你的代码来找出答案。