Output the same type of struct in function

I ran into a similar problem recently. I wanted to obtain the type of a variable but without any of the parameters, so that i can call the non-parametric constructor and let it figure out the parameters.

I ended up defining a function like this

typeofNoParam(::PLAN2)=PLAN2
typeofNoParam(::PLAN1)=PLAN1

and then use

typeofNoParam(model)(...)

instead of

typeof(model)(...)

It is similar to your solution with the initialize function, however, you don’t need to know the number of parameters to the constructor (PLAN1 and PLAN2).

EDIT: I just found an older thread that discussed the same issue with the same solution Extract type name only from parametric type