# What types are allowed inside struct?

**URL:** https://discourse.julialang.org/t/what-types-are-allowed-inside-struct/14090
**Category:** New to Julia
**Tags:** type
**Created:** [August 26, 2018, 5:43pm UTC](https://discourse.julialang.org/t/what-types-are-allowed-inside-struct/14090 "2018-08-26T17:43:41Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![wsrinin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wsrinin/32/7676_2.png) [@wsrinin](https://discourse.julialang.org/u/wsrinin)
#### Post date: [August 26, 2018, 5:43pm UTC](https://discourse.julialang.org/t/what-types-are-allowed-inside-struct/14090/1 "2018-08-26T17:43:41Z")

</div>

Hi, I am a little confused about what types are allowed to be declared for fields inside a struct. For example,

```julia
struct Foo
       list:: Tuple{Int64}
end

```

gives me an error that says " cannot covert object of type Tuple{Int64} to Tupule{}" when I try to instantiate the object, says foo((1,2)). However, I instead do

```julia
struct Foo
       list:: Tuple
end

```

It is fine. This is the same if I try to declare the type of the fieldnames to be a particular kind of dictionary. I think I am misunderstanding something very fundamental here. Any clarification or pointing to where to read in the document would be gladly appreciated.

---

<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: [August 26, 2018, 5:47pm UTC](https://discourse.julialang.org/t/what-types-are-allowed-inside-struct/14090/2 "2018-08-26T17:47:55Z")

</div>

All types are allowed to be fields of a struct. The issue in your case is that the type `Tuple{Int64}` means a tuple with _exactly one_ Int64. The type of `(1, 2)` is `Tuple{Int64, Int64}` so you can’t assign that to a field of type `Tuple{Int64}`.

---

<div class="post-metadata">

### Author: ![wsrinin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wsrinin/32/7676_2.png) [@wsrinin](https://discourse.julialang.org/u/wsrinin)
#### Post date: [August 26, 2018, 5:52pm UTC](https://discourse.julialang.org/t/what-types-are-allowed-inside-struct/14090/3 "2018-08-26T17:52:14Z")

</div>

> [@wsrinin](#):
>
> struct Foo list:: Tuple{Int64} end

Oh, thanks you. My bad in my mind I thought Tuple{Int64} implicitly impiles (int64, int64).

---

<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: [August 26, 2018, 6:03pm UTC](https://discourse.julialang.org/t/what-types-are-allowed-inside-struct/14090/4 "2018-08-26T18:03:40Z")

</div>

Yeah, I think people often think specifically of 2-tuples when they say “tuple”, but there’s nothing special about a 2-element tuple in Julia. You can have a tuple with any number of arguments, and the type signature just shows every element: `Tuple{Int}, Tuple{Int, Int}, Tuple{Int, Int, Int}`, etc.

But if you want a more convenient shorthand, you can also use `NTuple{N, Int}` to express a tuple of `N` `Int`s:

```julia
julia> Tuple{Int} === NTuple{1, Int}
true

julia> Tuple{Int, Int} === NTuple{2, Int}
true

julia> Tuple{Int, Int, Int} === NTuple{3, Int}
true

```
