# Help with \`Base.getproperty\` syntax

**URL:** <https://discourse.julialang.org/t/help-with-base-getproperty-syntax/16628>\
**Category:** General Usage\
**Created:** [October 22, 2018, 1:47pm UTC](https://discourse.julialang.org/t/help-with-base-getproperty-syntax/16628 "2018-10-22T13:47:36Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Post date:** [October 22, 2018, 2:03pm UTC](https://discourse.julialang.org/t/help-with-base-getproperty-syntax/16628/5 "2018-10-22T14:03:28Z")

</div>

You can still dispatch on the property name with

```julia
_getproperty(x::S, ::Val{s}) where {s} = getfield(x, s)
_getproperty(x::S, ::Val{:a}) = "a"

Base.getproperty(x::S, s::Symbol) = _getproperty(x, Val{s}())

```

However, you should only do this if you have a small number of property names, as there’s lots of potential for performance issues. It’s also a good idea to provide methods for `Base.propertynames`.

---

_[View the full topic](https://discourse.julialang.org/t/help-with-base-getproperty-syntax/16628)._
