# Functions as fields of mutable struct in if-elseif environment

**URL:** https://discourse.julialang.org/t/functions-as-fields-of-mutable-struct-in-if-elseif-environment/17342
**Category:** General Usage
**Created:** [November 9, 2018, 1:50pm UTC](https://discourse.julialang.org/t/functions-as-fields-of-mutable-struct-in-if-elseif-environment/17342 "2018-11-09T13:50:36Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)
#### Post date: [November 9, 2018, 2:06pm UTC](https://discourse.julialang.org/t/functions-as-fields-of-mutable-struct-in-if-elseif-environment/17342/2 "2018-11-09T14:06:24Z")

</div>

Use anonymous functions for `f` (`f = x -> x` and `f = x -> -x`), see e.g. [Defining a function inside if...else..end NOT as expected?](https://discourse.julialang.org/t/defining-a-function-inside-if-else-end-not-as-expected/13815). There is also an issue about this that I can’t find now.

---

_[View the full topic](https://discourse.julialang.org/t/functions-as-fields-of-mutable-struct-in-if-elseif-environment/17342)._
