You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Assuming i have a have piece of code which has an StructTypes.AbstractType() which already has it's StructTypes.subtypes(::Type{Vehicle}) set but i now want to add a new subtype at run time.
Is there a recommended way to do that? If so i would offer to extend the documentation with an example. My current solution would be StructTypes.subtypes(::Type{Vehicle}) = merge(StructTypes.subtypes(::Type{Vehicle}), (; train=Train)) but if there is a different way preferred with the package then i would like to know.
The text was updated successfully, but these errors were encountered:
I'm curious if there's a better solution, but I put this together yesterday. My understanding is that InteractiveUtils.subtypes is slow, but for my use case it doesn't matter.
functionconcrete_subtypes(T)
out = Type[]
for S insubtypes(T)
isconcretetype(S) ?push!(out, S) :append!(out, concrete_subtypes(S))
endreturn out
end
StructTypes.subtypes(::Type{T}) where {T <:MyAbstractType} =Dict(T.name.name => T for T inconcrete_subtypes(T))
Assuming i have a have piece of code which has an
StructTypes.AbstractType()
which already has it'sStructTypes.subtypes(::Type{Vehicle})
set but i now want to add a new subtype at run time.Is there a recommended way to do that? If so i would offer to extend the documentation with an example. My current solution would be
StructTypes.subtypes(::Type{Vehicle}) = merge(StructTypes.subtypes(::Type{Vehicle}), (; train=Train))
but if there is a different way preferred with the package then i would like to know.The text was updated successfully, but these errors were encountered: