I understand new{T}(...)
must be used instead of new(...)
to define an outer constructor inside struct ... end
(to define an outer-only constructor, for example).
However, when defining an inner constructor, is there any difference between new
and new{T}
? For example, I wonder if there is any difference between the following two:
julia> struct MyType{T}
x::T
MyType{T}(x) where {T} = new(x)
end
and
julia> struct MyType{T}
x::T
MyType{T}(x) where {T} = new{T}(x)
end
One uses new(...)
whereas the other uses new{T}(...)
.