# Problem with invoking objects of user defined types

**URL:** <https://discourse.julialang.org/t/problem-with-invoking-objects-of-user-defined-types/80017>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [April 25, 2022, 9:35pm UTC](https://discourse.julialang.org/t/problem-with-invoking-objects-of-user-defined-types/80017 "2022-04-25T21:35:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![math\_opt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/math_opt/32/25317_2.png) [@math\_opt](https://discourse.julialang.org/u/math_opt)\
**Post date:** [April 25, 2022, 9:35pm UTC](https://discourse.julialang.org/t/problem-with-invoking-objects-of-user-defined-types/80017/1 "2022-04-25T21:35:08Z")

</div>

Why am I not able to assign a value to a mutable struct field if I have not restricted it to a particular type for the following case:

```julia
mutable struct TestStruct
    field1
    field2
    function TestStruct(field1)
        new(field1, nothing)
    end
end

TestStruct(10) #returns TestStruct(12, nothing) as expected
TestStruct(10, 20) #throws method error: no method matching TestStruct(::Int64, ::Int64)

```

Can someone explain what’s wrong with creating the object the second way? I am pretty sure it’s something naive but I fail to understand it. Thank you!

---

<div class="post-metadata">

**Author:** ![Jeff\_Emanuel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff_emanuel/32/15440_2.png) [@Jeff\_Emanuel](https://discourse.julialang.org/u/Jeff_Emanuel)\
**Post date:** [April 25, 2022, 9:47pm UTC](https://discourse.julialang.org/t/problem-with-invoking-objects-of-user-defined-types/80017/2 "2022-04-25T21:47:57Z")

</div>

“If any inner constructor method is defined, no default constructor method is provided” [Constructors · The Julia Language](https://docs.julialang.org/en/v1/manual/constructors/#man-inner-constructor-methods)

---

<div class="post-metadata">

**Author:** ![math\_opt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/math_opt/32/25317_2.png) [@math\_opt](https://discourse.julialang.org/u/math_opt)\
**Post date:** [April 25, 2022, 9:50pm UTC](https://discourse.julialang.org/t/problem-with-invoking-objects-of-user-defined-types/80017/3 "2022-04-25T21:50:15Z")

</div>

Totally missed that line. Thanks!
