# Can not convert an object of type Tuple{Int64, Int64} to an object of type Tuple{}

**URL:** <https://discourse.julialang.org/t/can-not-convert-an-object-of-type-tuple-int64-int64-to-an-object-of-type-tuple/22990>\
**Category:** General Usage\
**Created:** [April 10, 2019, 9:42am UTC](https://discourse.julialang.org/t/can-not-convert-an-object-of-type-tuple-int64-int64-to-an-object-of-type-tuple/22990 "2019-04-10T09:42:39Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [April 10, 2019, 9:42am UTC](https://discourse.julialang.org/t/can-not-convert-an-object-of-type-tuple-int64-int64-to-an-object-of-type-tuple/22990/1 "2019-04-10T09:42:39Z")

</div>

```julia
mutable struct myTp
    a::Vector{Int64}
    b::Tuple{Int64}

    #myTp() = new([], ())
    myTp(a,b) = new(a,b)
end

function main()
    c=myTp([1,2,3],(4,5,6))
end

main()

```

Can anyone let me know why?

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [April 10, 2019, 9:48am UTC](https://discourse.julialang.org/t/can-not-convert-an-object-of-type-tuple-int64-int64-to-an-object-of-type-tuple/22990/2 "2019-04-10T09:48:55Z")

</div>

Consider:

```julia
julia> typeof((1,2,3))
Tuple{Int64,Int64,Int64}

julia> typeof((1,))
Tuple{Int64}

julia> typeof((1,2,3))==typeof((1,))
false

```

This means that the type of the tuple is dependent on all its components. Note that this is different to `Vector`. Maybe you’re looking for this:

```julia
julia> mutable struct MyTp{N}
           a::Vector{Int64}
           b::NTuple{N,Int64}
       end

julia> MyTp([1,2,3],(4,5,6))
MyTp{3}([1, 2, 3], (4, 5, 6))

```

---

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [April 10, 2019, 11:20am UTC](https://discourse.julialang.org/t/can-not-convert-an-object-of-type-tuple-int64-int64-to-an-object-of-type-tuple/22990/3 "2019-04-10T11:20:44Z")

</div>

`N` in `mutable struct MyTp{N}` is the same as `T` in

```julia
mutable struct Point{T<:Real}
      x::T 
      y::T 
end 

```

They are called parametric constructors.

---

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [April 10, 2019, 11:24am UTC](https://discourse.julialang.org/t/can-not-convert-an-object-of-type-tuple-int64-int64-to-an-object-of-type-tuple/22990/4 "2019-04-10T11:24:39Z")

</div>

```julia
mutable struct myTp{N}
    a::Vector{Int64}
    b::NTuple{N,Int64}

    #myTp() = new([], ())
    #myTp(a,b) = new(a,b)
end

function main()
    c=myTp([1,2,3],(4,5,6))
end

main()

```

Got an error " invalid redefinition of constant myTp".

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [April 10, 2019, 11:25am UTC](https://discourse.julialang.org/t/can-not-convert-an-object-of-type-tuple-int64-int64-to-an-object-of-type-tuple/22990/5 "2019-04-10T11:25:50Z")

</div>

Restart the REPL

---

<div class="post-metadata">

**Author:** ![bsnyh](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@bsnyh](https://discourse.julialang.org/u/bsnyh)\
**Post date:** [April 10, 2019, 12:15pm UTC](https://discourse.julialang.org/t/can-not-convert-an-object-of-type-tuple-int64-int64-to-an-object-of-type-tuple/22990/6 "2019-04-10T12:15:15Z")

</div>

This is something I do not quite understand. Why restarting the REPL would solve it?

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [April 10, 2019, 12:37pm UTC](https://discourse.julialang.org/t/can-not-convert-an-object-of-type-tuple-int64-int64-to-an-object-of-type-tuple/22990/7 "2019-04-10T12:37:04Z")

</div>

Because you cannot redefine types:

```julia
julia> struct A
       a
       end

julia> struct A
       a
       b
       end
ERROR: invalid redefinition of constant A
Stacktrace:
 [1] top-level scope at none:0

```

---

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [June 6, 2020, 10:33pm UTC](https://discourse.julialang.org/t/can-not-convert-an-object-of-type-tuple-int64-int64-to-an-object-of-type-tuple/22990/8 "2020-06-06T22:33:11Z")

</div>

If I cannot redefine types, that means that I must get the structure correct on the first time. When restarting the REPL, one loses a few minutes for various precompilations. That is very suboptimal in terms of workflow. What is a way around this. Thanks.

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [June 7, 2020, 12:51am UTC](https://discourse.julialang.org/t/can-not-convert-an-object-of-type-tuple-int64-int64-to-an-object-of-type-tuple/22990/9 "2020-06-07T00:51:05Z")

</div>

Two things:

1. You must have been warned by Discourse to not reply to old discussions to avoid bothering all the old participants of the discussion. This is to be avoided. Create new topics instead.
2. A quick search in google or in discourse return [this answer](https://discourse.julialang.org/t/redefine-struct-when-working-with-repl/25942).

---

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [June 7, 2020, 3:08am UTC](https://discourse.julialang.org/t/can-not-convert-an-object-of-type-tuple-int64-int64-to-an-object-of-type-tuple/22990/10 "2020-06-07T03:08:30Z")

</div>

1. Thanks. I was not warned.
2. Thanks. I had read and did not understand the answer. I now put my structures in a separate module.
