# Method works in REPL; can't use in a function body

**URL:** <https://discourse.julialang.org/t/method-works-in-repl-cant-use-in-a-function-body/36332>\
**Category:** General Usage\
**Created:** [March 22, 2020, 5:01am UTC](https://discourse.julialang.org/t/method-works-in-repl-cant-use-in-a-function-body/36332 "2020-03-22T05:01:19Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [March 22, 2020, 7:03am UTC](https://discourse.julialang.org/t/method-works-in-repl-cant-use-in-a-function-body/36332/2 "2020-03-22T07:03:57Z")

</div>

It is hard to debug this without an MWE.

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757/):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …

There is probably a global variable that does not have the value you think it has. Try to write cleaner code, passing all arguments needed to a function — eg `infectious` for `spread`.

---

_[View the full topic](https://discourse.julialang.org/t/method-works-in-repl-cant-use-in-a-function-body/36332)._
