AlexS12 / FlightMechanicsSimulator.jl

Flight Mechanics Engine
MIT License
9 stars 2 forks source link

Consider using Parameters.jl #32

Open AlexS12 opened 3 years ago

AlexS12 commented 3 years ago

https://github.com/mauro3/Parameters.jl

Some interesting examples:

struct B
    a
    b
    c
end
@unpack a, c = B(4,5,6)
# is equivalent to
BB = B(4,5,6)
a = BB.a
c = BB.c
julia> using Parameters

julia> @with_kw struct A
           a::Int = 6
           b::Float64 = -1.1
           c::UInt8
       end

julia> A(c=4)
A
  a: 6
  b: -1.1
  c: 4

julia> A()
ERROR: Field 'c' has no default, supply it with keyword.

julia> A(c=4, a = 2)
A
  a: 2
  b: -1.1
  c: 4