# Output the same type of struct in function

**URL:** <https://discourse.julialang.org/t/output-the-same-type-of-struct-in-function/27218>\
**Category:** New to Julia\
**Created:** [August 6, 2019, 2:11pm UTC](https://discourse.julialang.org/t/output-the-same-type-of-struct-in-function/27218 "2019-08-06T14:11:13Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![martink](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@martink](https://discourse.julialang.org/u/martink)\
**Post date:** [August 15, 2019, 5:06pm UTC](https://discourse.julialang.org/t/output-the-same-type-of-struct-in-function/27218/12 "2019-08-15T17:06:43Z")

</div>

> [@jbrea](#):
>
> If you want the type without parameters, you can get it with `typeof(plan2).name.wrapper`, but I would disencourage relying on “internal” fields like `name` and `wrapper`.

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

```julia
typeofNoParam(::PLAN2)=PLAN2
typeofNoParam(::PLAN1)=PLAN1

```

and then use

```julia
typeofNoParam(model)(...)

```

instead of

```julia
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](https://discourse.julialang.org/t/extract-type-name-only-from-parametric-type/14188)

---

_[View the full topic](https://discourse.julialang.org/t/output-the-same-type-of-struct-in-function/27218)._
