# How to set the elements of an array of defined type in one line?

**URL:** <https://discourse.julialang.org/t/how-to-set-the-elements-of-an-array-of-defined-type-in-one-line/66171>\
**Category:** General Usage\
**Created:** [August 11, 2021, 4:52am UTC](https://discourse.julialang.org/t/how-to-set-the-elements-of-an-array-of-defined-type-in-one-line/66171 "2021-08-11T04:52:01Z")\
**Posts on this page:** 1\
**Showing post:** 21

<div class="post-metadata">

**Author:** ![CRquantum](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/crquantum/32/27824_2.png) [@CRquantum](https://discourse.julialang.org/u/CRquantum)\
**Post date:** [August 11, 2021, 7:56am UTC](https://discourse.julialang.org/t/how-to-set-the-elements-of-an-array-of-defined-type-in-one-line/66171/21 "2021-08-11T07:56:06Z")

</div>

Thank you very much!  
Indeed, I was thinking of some more generic/native solutions such as just using for \_ in 1:2 as you suggested, something similar with the link below,

> [@How to define many variables in few lines?](https://discourse.julialang.org/t/how-to-define-many-variables-in-few-lines/65788/4):
>
> Maybe something like this: (a,b,c,d,e) = (Ref{Float64}(1.0) for \_ in 1:5)

---

_[View the full topic](https://discourse.julialang.org/t/how-to-set-the-elements-of-an-array-of-defined-type-in-one-line/66171)._
