Can some tell me why the last line does not work?
How can I add a constructor that does the same as the default constructor?
(i.e. Rulepath(1,v,true) works as expected)
struct Rulepath{T<:Unsigned}
featid::Int64
subset::Vector{T}
isLeftChild::Bool
end
v=UInt16[1,2,9]
Rulepath(1,v,true) #works
#however, I prefer to have different constructors:
struct Rulepath2{T<:Unsigned}
featid::Int64
subset::Vector{T}
isLeftChild::Bool
function Rulepath2{T}() where T<:Unsigned
return new(0,UInt8[],false)
end
function Rulepath2{T}(a,b::Vector{T},c) where T<:Unsigned
return new(a,b,c)
end
end
v=UInt16[1,2,9]
Rulepath2{UInt8}() #works
Rulepath2{eltype(v)}(1,v,true) #works
Rulepath2(1,v,true) #fails