I’m totally new to Julia, and I was hoping for a simple explanation of the error in the title of this post. Other posts I’ve read say something about conditionally defining functions. But I’m encountering this error in a simple loop:
function sum(x) z = 0 for i = 1:x z = z + 1 end return z end sum(10)
(obviously a illustrative example)
I think it has something to do with the fact that the variable z is defined and modified in the function.
I’d like to know exactly what the problem is here and how I can avoid it. May be something very simple, but still very confusing for a beginner.