This is a feature.
The variable defined outside the function is a global variable.
If you intended to write to that inside the function, use
function test_fn()
print(test_vec)
global test_vec = zeros(5)
end
Much more details
at http://docs.julialang.org/en/latest/manual/variables-and-scoping/
On Saturday, 18 January 2014 21:52:29 UTC, Bob Quazar wrote:
>
> Running the code below gives the error message "ERROR: test_vec not
> defined". Why does this happen? Is it a bug or a feature? (I'm using Julia
> 0.2 on Linux.)
>
> Thanks, Bob
>
>
>
>> test_vec = zeros(4)
>> function test_fn()
>> print(test_vec)
>> test_vec = zeros(5)
>> end
>> test_fn()
>
>
>