Hi,
I am reading the code of Base libraries to improve my understanding and
style. In base/dates/types.jl, I noticed
for T in (:Year,:Month,:Week,:Day)
@eval immutable $T <: DatePeriod
value::Int64
$T(v::Number) = new(v)
end
end
which expands to code like
immutable Year <: DatePeriod
value::Int64
Year(v::Number) = new(v)
end
I have a simple question: what is the reason for defining the inner
constructor? Wouldn't
immutable Year <: DatePeriod
value::Int64
end
automatically define one, except for restricting to ::Number? If that is
the reason, I would like to understand why.
Best,
Tamas