# UndefVarError: .\* not defined

**URL:** <https://discourse.julialang.org/t/undefvarerror-not-defined/16517>\
**Category:** General Usage\
**Created:** [October 19, 2018, 2:42am UTC](https://discourse.julialang.org/t/undefvarerror-not-defined/16517 "2018-10-19T02:42:44Z")\
**Posts on this page:** 1\
**Showing post:** 17

<div class="post-metadata">

**Author:** ![bennedich](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bennedich/32/4894_2.png) [@bennedich](https://discourse.julialang.org/u/bennedich)\
**Post date:** [October 20, 2018, 8:45pm UTC](https://discourse.julialang.org/t/undefvarerror-not-defined/16517/17 "2018-10-20T20:45:56Z")

</div>

The Julian way to solve this is to use composition over inheritance. This has been discussed in [this thread](https://discourse.julialang.org/t/workaround-for-traditional-inheritance-features-in-object-oriented-languages/1195).

I am also with Tamas; if I saw a source file with hundreds of such structs (_mutable_ even!), it would strongly suggest to me that there are better ways to do it. (Although I’m sure there are rare exceptions.)

For the example you mention, you could imagine binding the `process` function to the fruit:

```julia
struct Fruit
    name::String
    process::Function
end

apple = Fruit("Apple", () -> println("apple"))
orange = Fruit("Orange", () -> println("orange"))
another_orange = Fruit("My Other Orange", orange.process)

apple.process() # => "apple"
another_orange.process() # => "orange"

# or:
process(fruit) = fruit.process()
process(apple)

```

Inheritance/hierarchy could be achieved by having a `parent` field in the struct.

---

_[View the full topic](https://discourse.julialang.org/t/undefvarerror-not-defined/16517)._
