# What's the correct way of defining struct with an Integer Parameter?

**URL:** <https://discourse.julialang.org/t/whats-the-correct-way-of-defining-struct-with-an-integer-parameter/23974>\
**Category:** New to Julia\
**Created:** [May 7, 2019, 5:57pm UTC](https://discourse.julialang.org/t/whats-the-correct-way-of-defining-struct-with-an-integer-parameter/23974 "2019-05-07T17:57:19Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [May 7, 2019, 6:04pm UTC](https://discourse.julialang.org/t/whats-the-correct-way-of-defining-struct-with-an-integer-parameter/23974/2 "2019-05-07T18:04:46Z")

</div>

Your definition isn’t quite doing what you think, because `D <: Integer` is not the right condition. `D <: Integer` says that `D` is a _type_ which is some subtype of `Integer`, not that `D` is a _value_ whose type is `<: Integer`. For example:

```julia
julia> Int <: Integer
true

julia> Int32 <: Integer
true

julia> 33 <: Integer
ERROR: TypeError: in <:, expected Type, got Int64
Stacktrace:
 [1] top-level scope at none:0

```

Instead, you need to check the condition on `D` inside an inner constructor. See [Restrict type of value type parameter - #2 by Tamas\_Papp](https://discourse.julialang.org/t/restrict-type-of-value-type-parameter/12127/2) for an example.

---

_[View the full topic](https://discourse.julialang.org/t/whats-the-correct-way-of-defining-struct-with-an-integer-parameter/23974)._
