# Setfield.jl for parametric type

**URL:** <https://discourse.julialang.org/t/setfield-jl-for-parametric-type/71670>\
**Category:** General Usage\
**Tags:** question, setfield\
**Created:** [November 17, 2021, 4:05pm UTC](https://discourse.julialang.org/t/setfield-jl-for-parametric-type/71670 "2021-11-17T16:05:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ohmsweetohm1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ohmsweetohm1/32/49126_2.png) [@ohmsweetohm1](https://discourse.julialang.org/u/ohmsweetohm1)\
**Post date:** [November 17, 2021, 4:05pm UTC](https://discourse.julialang.org/t/setfield-jl-for-parametric-type/71670/1 "2021-11-17T16:05:55Z")

</div>

```julia
struct B{T, X, Y}
    x::X
    y::Y
end

B{T}(x::X, y::Y = 2) where {T, X, Y} = B{T, X, Y}(x, y)

b = B{Int}(2,3)

Setfield.@set b.x = 512 # fails

```
