# Calling a struct as a function

**URL:** <https://discourse.julialang.org/t/calling-a-struct-as-a-function/4911>\
**Category:** General Usage\
**Tags:** question\
**Created:** [July 17, 2017, 8:40pm UTC](https://discourse.julialang.org/t/calling-a-struct-as-a-function/4911 "2017-07-17T20:40:26Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![robertdj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/robertdj/32/103_2.png) [@robertdj](https://discourse.julialang.org/u/robertdj)\
**Post date:** [July 17, 2017, 9:06pm UTC](https://discourse.julialang.org/t/calling-a-struct-as-a-function/4911/2 "2017-07-17T21:06:15Z")

</div>

For a `type` in v0.5 you could define a function like this that allows the syntax `b = a(2,1)` (it’s probably the same for a `struct` in v0.6):

```julia
function (a::BitNumber)(width, val)
...
end

```

---

_[View the full topic](https://discourse.julialang.org/t/calling-a-struct-as-a-function/4911)._
