# Optional argument is a struct

**URL:** <https://discourse.julialang.org/t/optional-argument-is-a-struct/64502>\
**Category:** New to Julia\
**Created:** [July 12, 2021, 11:51am UTC](https://discourse.julialang.org/t/optional-argument-is-a-struct/64502 "2021-07-12T11:51:43Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Nathan\_Boyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nathan_boyer/32/14825_2.png) [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)\
**Post date:** [July 12, 2021, 12:59pm UTC](https://discourse.julialang.org/t/optional-argument-is-a-struct/64502/6 "2021-07-12T12:59:48Z")

</div>

I’ll share some advice I was given.

1. Define a function `_fun` that does the bulk of the work. Then have methods `fun(a, b, c)` and `fun(a, b)` both call `_fun` internally but with different pre- and post-processing above and below respectively.
2. You can use a distinct `struct` rather than `nothing` to define methods for your different cases: [Application Code Organization - #15 by lmiq](https://discourse.julialang.org/t/application-code-organization/53224/15).

---

_[View the full topic](https://discourse.julialang.org/t/optional-argument-is-a-struct/64502)._
