jw3126 / Setfield.jl

Update deeply nested immutable structs.
Other
167 stars 17 forks source link

Parametric Types #180

Open Lincoln-Hannah opened 3 months ago

Lincoln-Hannah commented 3 months ago

Is there a syntax that works with parametric types. The below gives an error.

struct A{T}
    a::Int64
end

x = A{1}(1)

@Setfield.set x.a = 2
jw3126 commented 3 months ago

It is a recurring question. The answer is no, see the following for why and alternative patterns: