Under Julia v0.6, the simple code:
julia> struct A
x::Int = 1
end
generates this error:
ERROR: syntax: "x::Int=1" inside type definition is reserved
This is quite an elusive message: reserved for what?
-> Do I have to understand that this kind of definition is going to be allowed in future Julia revisions?
This is available via Parameters.jl.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With