# Is it possible to create a struct instance without an explicit constructor?

**URL:** <https://discourse.julialang.org/t/is-it-possible-to-create-a-struct-instance-without-an-explicit-constructor/64243>\
**Category:** General Usage\
**Created:** [July 7, 2021, 11:22pm UTC](https://discourse.julialang.org/t/is-it-possible-to-create-a-struct-instance-without-an-explicit-constructor/64243 "2021-07-07T23:22:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Visipi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/visipi/32/21206_2.png) [@Visipi](https://discourse.julialang.org/u/Visipi)\
**Post date:** [July 7, 2021, 11:22pm UTC](https://discourse.julialang.org/t/is-it-possible-to-create-a-struct-instance-without-an-explicit-constructor/64243/1 "2021-07-07T23:22:30Z")

</div>

I have this problem where I’m given a DataType for a mutable struct and I have a lot of values corresponding to all the fields for this struct. Trouble is that these values might be out of order so I have no way of loading them into the default constructor foo(“a”, “b”, … “z”)

It would be great if I could create a struct instance with dummy values and then update everything one by one without going off and defining a foo() for each of my structs. Is there a way to do this? Probably I’m just lazy and need better style -.-

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [July 7, 2021, 11:47pm UTC](https://discourse.julialang.org/t/is-it-possible-to-create-a-struct-instance-without-an-explicit-constructor/64243/2 "2021-07-07T23:47:13Z")

</div>

If you use the `Base.@kwdef` you can use keywords to intialize the values. That in combination with `keys()`, `values()`, `fieldnames()`, can give you the tools to build complicated constructors.

(If your structure is mutable maybe just using @kwdef solves all your problems)
