[英]Argument Error for Date.new
I wrote this code: 我写了这段代码:
[1,2,3,4].each do |f|
@date = Date.new(2014,f * 3,1)
@begin = @date.beginning_of_quarter
@end = @date.end_of_quarter
puts f + " Quartal von " + @begin + " bis " + @end
end
Somehow i get the error: 我以某种方式得到错误:
DateTest.rb:2:in `initialize': wrong number of arguments (3 for 0) (ArgumentError)
from DateTest.rb:2:in `new'
from DateTest.rb:2:in `block in <main>'
from DateTest.rb:1:in `each'
from DateTest.rb:1:in `<main>'
What did i wrong? 我怎么了 Thanks!
谢谢!
You passed three arguments to the original Date.new
, which does not take any argument. 您向原始
Date.new
传递了三个参数,该参数没有任何参数。 The one that takes arguments is the one overwritten by the "date"
library. 接受参数的是被
"date"
库覆盖的参数。 In order to use it, you need to do 为了使用它,您需要做
require "date"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.