# Is there a shorthand to make all fields of a struct the same type?

**URL:** <https://discourse.julialang.org/t/is-there-a-shorthand-to-make-all-fields-of-a-struct-the-same-type/98961>\
**Category:** General Usage\
**Tags:** macros, type, struct\
**Created:** [May 16, 2023, 11:05pm UTC](https://discourse.julialang.org/t/is-there-a-shorthand-to-make-all-fields-of-a-struct-the-same-type/98961 "2023-05-16T23:05:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lincoln\_Hannah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lincoln_hannah/32/19198_2.png) [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Post date:** [May 16, 2023, 11:05pm UTC](https://discourse.julialang.org/t/is-there-a-shorthand-to-make-all-fields-of-a-struct-the-same-type/98961/1 "2023-05-16T23:05:10Z")

</div>

E.g

```julia
struct myStruct
     ::Float64 #apply to all
      a
      b
      c
end

```

---

<div class="post-metadata">

**Author:** ![Zentrik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zentrik/32/35409_2.png) [@Zentrik](https://discourse.julialang.org/u/Zentrik)\
**Post date:** [May 16, 2023, 11:20pm UTC](https://discourse.julialang.org/t/is-there-a-shorthand-to-make-all-fields-of-a-struct-the-same-type/98961/2 "2023-05-16T23:20:52Z")

</div>

[mauro3/Parameters.jl: Types with default field values, keyword constructors and (un-)pack macros (github.com)](https://github.com/mauro3/Parameters.jl) has a `@deftype` macro.  
E.g.

```julia
@with_kw struct myStruct @deftype Float64
    a
    b
    c 
end

```
