# Restrict type of value type parameter

**URL:** <https://discourse.julialang.org/t/restrict-type-of-value-type-parameter/12127>\
**Category:** General Usage\
**Tags:** question\
**Created:** [July 3, 2018, 1:44pm UTC](https://discourse.julialang.org/t/restrict-type-of-value-type-parameter/12127 "2018-07-03T13:44:47Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [July 3, 2018, 2:27pm UTC](https://discourse.julialang.org/t/restrict-type-of-value-type-parameter/12127/2 "2018-07-03T14:27:44Z")

</div>

I think that `NTuple` _per se_ does not check that `N` is an integer, `Vararg` (which it is aliased to) does.

For `struct`s, the recommended solution is to check in the inner constructor, eg

```julia
struct A{L}
    function A{L}() where L
        @assert L isa Integer
        new{L}()
    end
end

A(L::Integer) = A{L}() # convenience constructor

A(1) # OK
A("a fish") # error

```

---

_[View the full topic](https://discourse.julialang.org/t/restrict-type-of-value-type-parameter/12127)._
