# Struct Parametric struct with type constrains in Union

**URL:** <https://discourse.julialang.org/t/struct-parametric-struct-with-type-constrains-in-union/46854>\
**Category:** General Usage\
**Tags:** question\
**Created:** [September 18, 2020, 3:55pm UTC](https://discourse.julialang.org/t/struct-parametric-struct-with-type-constrains-in-union/46854 "2020-09-18T15:55:16Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![efokken](https://avatars.discourse-cdn.com/v4/letter/e/b5a626/32.png) [@efokken](https://discourse.julialang.org/u/efokken)\
**Post date:** [September 18, 2020, 4:11pm UTC](https://discourse.julialang.org/t/struct-parametric-struct-with-type-constrains-in-union/46854/3 "2020-09-18T16:11:24Z")

</div>

Thanks for the fast answer!  
The drawback seems to be that the resulting type changes, if I understand it correctly depending on what concrete type I use in each `thing`.

Is the following solution I found better?  
(Taken from [different topic](https://discourse.julialang.org/t/having-a-little-trouble-with-recursively-defined-structs/22285) )

```julia
struct thin{T}
    p::Union{Float64,T}
    someother_member
    function thin{T}(p,someother_member) where {T}
        T <: Function || throw(ArgumentError("invalid type"))
        new{T}(p,someother_member)
    end  
end

```

I can call every type of `p` via `thing{Function}(p0,some0)` and it has the type

```julia
thing{function}

```

I just don’t know whether that is a performance advantage.

---

_[View the full topic](https://discourse.julialang.org/t/struct-parametric-struct-with-type-constrains-in-union/46854)._
