Reputation: 10982
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?
Upvotes: 4
Views: 1856
Reputation: 19132
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
Upvotes: 7