# Examples of \`getproperty\`, \`setproperty!\`, ... usage

**URL:** <https://discourse.julialang.org/t/examples-of-getproperty-setproperty-usage/15368>\
**Category:** General Usage\
**Tags:** question\
**Created:** [September 23, 2018, 9:28am UTC](https://discourse.julialang.org/t/examples-of-getproperty-setproperty-usage/15368 "2018-09-23T09:28:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmbates](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmbates/32/44_2.png) [@dmbates](https://discourse.julialang.org/u/dmbates)\
**Post date:** [September 23, 2018, 9:28am UTC](https://discourse.julialang.org/t/examples-of-getproperty-setproperty-usage/15368/1 "2018-09-23T09:28:17Z")

</div>

Can someone suggest packages to check for examples of the use of `getproperty`, `setproperty!`, etc.? I currently have functions named `getθ`, `setθ!`, … in the MixedModels package. The θ vector is a property of the model but not a field in the `LinearMixedModel` struct. It needs to be assembled from other pieces when extracting and to be spread over those pieces when setting a new value. This seems to be a natural usage of the `getproperty`, … scheme but I want to make sure I don’t miss subtleties when implementing it.

Having written the question, I suppose that the `LinearAlgebra` package is a good place to start. Other suggestions?

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [September 23, 2018, 11:24am UTC](https://discourse.julialang.org/t/examples-of-getproperty-setproperty-usage/15368/2 "2018-09-23T11:24:46Z")

</div>

I don’t think there are any subtleties. Maybe only that you probably also want to implement `propertynames` (for auto-completion) and the soon to come [`hasproperty`](https://github.com/JuliaLang/julia/issues/28850).

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [September 23, 2018, 11:45am UTC](https://discourse.julialang.org/t/examples-of-getproperty-setproperty-usage/15368/3 "2018-09-23T11:45:31Z")

</div>

Heavily WIP and subject to change, and not claiming to be “correct”, but [this](https://github.com/tpapp/LogDensityProblems.jl/blob/dc30ad4736dce68abf9e9c386aff35b080af28a5/src/LogDensityProblems.jl#L140-L164) code forwards anything it cannot find in the object to a “parent”.

---

<div class="post-metadata">

**Author:** ![ianfiske](https://avatars.discourse-cdn.com/v4/letter/i/58f4c7/32.png) [@ianfiske](https://discourse.julialang.org/u/ianfiske)\
**Post date:** [October 22, 2018, 2:25pm UTC](https://discourse.julialang.org/t/examples-of-getproperty-setproperty-usage/15368/4 "2018-10-22T14:25:09Z")

</div>

I had the same issue, trouble getting this working. Got a working answer here [Help with `Base.getproperty` syntax - #2 by kristoffer.carlsson](https://discourse.julialang.org/t/help-with-base-getproperty-syntax/16628/2).
