# How to define many variables in few lines?

**URL:** <https://discourse.julialang.org/t/how-to-define-many-variables-in-few-lines/65788>\
**Category:** General Usage\
**Created:** [August 4, 2021, 6:38am UTC](https://discourse.julialang.org/t/how-to-define-many-variables-in-few-lines/65788 "2021-08-04T06:38:48Z")\
**Posts on this page:** 2\
**Page:** 3

<div class="post-metadata">

**Author:** ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Post date:** [August 19, 2021, 10:10pm UTC](https://discourse.julialang.org/t/how-to-define-many-variables-in-few-lines/65788/41 "2021-08-19T22:10:41Z")

</div>

> [@CRquantum](#):
>
> All those r8 and i8 variables and allocable arrays are stored in the module, and their values can change. So that in my Fortran code, I do not need to put every of them in the arguments of any function.

Yeah, don’t do this. Create a struct that defines your “problem” which has all those values as fields, and then pass the struct to your functions.

I see you already figured this out:

> [@CRquantum](#):
>
> create a struct to include all of them within a type, then put this type object in the arguments of the functions.

---

<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 20, 2021, 7:27am UTC](https://discourse.julialang.org/t/how-to-define-many-variables-in-few-lines/65788/42 "2021-08-20T07:27:27Z")

</div>

> [@DNF](#):
>
> `a, b, c = (Float64[] for _ in 1:6)`

Thank you all @DNF @jling @lmiq @dlakelan @pdeffebach @Nathan_Boyer @Vasily_Pisarev @lungben @jzr @carstenbauer etc (Sorry it only allow me to mention 10)

All the solutions are great!

Perhaps for a beginner like me, for now things like

```
a, b, c = (Float64[] for _ in 1:99999)

```

can be a easy and one size fits all solution. It also reminds me of the Implied do loop in Fortran.

But I believe fancy stuff like @jling did is also very useful!  
Thank you all, I very much enjoy reading all of your threads!

[Previous page](https://discourse.julialang.org/t/how-to-define-many-variables-in-few-lines/65788.md?page=2)
