# Multiple fields per line in struct declaration

**URL:** <https://discourse.julialang.org/t/multiple-fields-per-line-in-struct-declaration/45345>\
**Category:** General Usage\
**Created:** [August 22, 2020, 12:27am UTC](https://discourse.julialang.org/t/multiple-fields-per-line-in-struct-declaration/45345 "2020-08-22T00:27:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pauljurczak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pauljurczak/32/921_2.png) [@pauljurczak](https://discourse.julialang.org/u/pauljurczak)\
**Post date:** [August 22, 2020, 12:27am UTC](https://discourse.julialang.org/t/multiple-fields-per-line-in-struct-declaration/45345/1 "2020-08-22T00:27:51Z")

</div>

I have a `struct` with many fields, which can be logically grouped, like this, but more fields:

```julia
mutable struct Limits
  vMin::Float32
  vMax::Float32
  aMin::Float32
  aMax::Float32
end

```

Is there any way to write it similar to:

```julia
mutable struct Limits
  vMin::Float32, vMax::Float32
  aMin::Float32, aMax::Float32
end

```

or perhaps closer to (don’t mind the syntax):

```julia
mutable struct Limits
  vMin, vMax, aMin, aMax ::Float32
end

```

with the type specified only once, but applicable to all fields in that line?

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [August 22, 2020, 12:33am UTC](https://discourse.julialang.org/t/multiple-fields-per-line-in-struct-declaration/45345/2 "2020-08-22T00:33:02Z")

</div>

You can do:

```julia
mutable struct Limits
    vMin::Float32; vMax::Float32
    aMin::Float32; aMax::Float32
end

```

As newlines and semicolons are interchangeable.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [August 22, 2020, 5:17am UTC](https://discourse.julialang.org/t/multiple-fields-per-line-in-struct-declaration/45345/3 "2020-08-22T05:17:51Z")

</div>

> [@pauljurczak](#):
>
> the type specified only once, but applicable to all fields in that line?

Or you can do a

```julia
mutable struct Limits{T}
  vMin::T
  vMax::T
  aMin::T
  aMax::T
end

```

and just use the type for `Float32`. That said, whenever I work with

> [@pauljurczak](#):
>
> many fields, which can be logically grouped

I try to organize them somewhat into smaller structures or tuples. Eg if you don’t need to modify extrema separately, you can do

```julia
mutable struct Limits{T}
    v_extrema::Tuple{T,T}
    a_extrema::Tuple{T,T}
end

```

or even define a (mutable) struct for extrema, depending on your application.

---

<div class="post-metadata">

**Author:** ![cstjean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cstjean/32/1444_2.png) [@cstjean](https://discourse.julialang.org/u/cstjean)\
**Post date:** [August 22, 2020, 7:53am UTC](https://discourse.julialang.org/t/multiple-fields-per-line-in-struct-declaration/45345/4 "2020-08-22T07:53:21Z")

</div>

With [QuickTypes](https://github.com/cstjean/QuickTypes.jl)

```julia
julia> using QuickTypes

julia> @qmutable Limits(vMin::Float32, vMax::Float32,
                        aMin::Float32, aMax::Float32)

```
