Question: To create a struct I can do one of the following:

```
// Method 1
Item *item = malloc(sizeof(Item));
Item _item = {.name="job"};
item = &_item;

// Method 2
Item *item = malloc(sizeof(Item));
item->name="job";

```

Is there a simpler method to do this? Perhaps something along the lines of:

```
malloc(sizeof(Item)) & (Item) {.name="job"}

```

Here are the two methods: <https://godbolt.org/z/MfYGW3>

Answer: 
I prefer using `Parameters.jl` because it provides also a nicer way the `struct`s are displayed which is much nicer for debugging:

```
julia> using Parameters

julia> @with_kw struct A          
       a::Int=5                   
       b::String="hello"          
       c::Float64                 
       end;                                 

julia> A(c=3.5)                   
A                                 
  a: Int64 5                      
  b: String "hello"               
  c: Float64 3.5                  

```
Or you can also just go the long way and define it yourself with constructors, as you would normally do if you want to instantiate it in several possible ways.

```
mutable struct Scale                                                                                                                                                                                                                          
    # Set default values that will be changed by fit!()
    domain_min::Float64      
    domain_max::Float64      
    range_min::Float64        
    range_max::Float64       
end

# With default values, but no keywords
julia> Scale(dmin=1.,dmax=2.,rmin=1.,rmax=2.) = Scale(dmin, dmax, rmin, rmax)
Scale

julia> Scale(3.,4.)
Scale(3.0, 4.0, 1.0, 2.0)

# With keyword arguments:
julia> Scale(;dmin=1.,dmax=2.,rmin=1.,rmax=2.) = Scale(dmin, dmax, rmin, rmax)
Scale

julia> Scale(rmax=3., rmin=1.2)
Scale(1.0, 2.0, 1.2, 3.0)

```

Notice the difference between the two constructors, one has a semicolon `;` the other not. I would not recommend using both constructors at the same time, this may lead to some confusion.