如何在rake任务中将float number作为参数传递
desc "example rake"
task :to_store_number, [:number1, :number2] do |t, args|
a = "#{args[:number1].to_f}" * "#{args[:number2].to_f}"
puts a
end
出现错误“TypeError:没有将String隐式转换为整数”
答案 0 :(得分:1)
传递像args [:number]这样的参数而不是"#{args [:number]}"修好了
desc "example rake"
task :to_store_number, [:number1, :number2] do |t, args|
a = args[:number1].to_f * args[:number2].to_f
puts a
end