# Instantiate concrete type programmaticaly

**URL:** <https://discourse.julialang.org/t/instantiate-concrete-type-programmaticaly/113071>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [April 17, 2024, 2:08pm UTC](https://discourse.julialang.org/t/instantiate-concrete-type-programmaticaly/113071 "2024-04-17T14:08:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sigmund](https://avatars.discourse-cdn.com/v4/letter/s/b38774/32.png) [@Sigmund](https://discourse.julialang.org/u/Sigmund)\
**Post date:** [April 17, 2024, 2:08pm UTC](https://discourse.julialang.org/t/instantiate-concrete-type-programmaticaly/113071/1 "2024-04-17T14:08:23Z")

</div>

I want to instantiate a the following concrete type,

```julia
Base.@kwdef struct A
    x::Int
    y::Int = 123
end

```

but I’m having problems when all fields are not given.  
While this works:

```julia
julia> a = A([1, 2]...)
A(1, 2)

julia> A(x=1)
A(1, 123)

```

But the following does not work:

```julia
julia> A([1]...)
ERROR: MethodError: no method matching A(::Int64)

```

Note that I want to instantiate a composite type where the values for all (or the required) fields are given in a vector. How can I achieve this?

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [April 17, 2024, 2:45pm UTC](https://discourse.julialang.org/t/instantiate-concrete-type-programmaticaly/113071/2 "2024-04-17T14:45:57Z")

</div>

Does this work for you?

```julia
julia> A(; (x=1,)...)
A(1, 123)

julia> A(; NamedTuple{(:x,)}([1]...)...)
A(1, 123)

```
