Julia error VS Code and Juno / Error Julia VS Code and Juno

Asked

Viewed 72 times

1

When I try to make a basic program like this in VS Code:

n = 0
while n < 10
    n+=1
    println(n)
end

i get this mistake:

    ERROR: syntax: unexpected end

I tried to do the same program on Juno (the Juliapro version) and I get this other error, which also doesn’t make sense to me:

    LoadError: UndefVarError: n not defined

what mistake I’m making?

  • but can not be in another language, along with Portuguese?

  • 1

    There is no reason. All users of this site speak Portuguese. English would only be if you post your question on [so], which although it is from the same network, is a different site.

1 answer

0

According to the documentation of Julia, you must do so:

julia> i = 1;

julia> while i <= 5
           println(i)
           global i += 1
       end

The error that appeared is due to variable n be declared out of scope as is described here, example:

julia> a
ERROR: UndefVarError: a not defined

julia> a = 1;

julia> a
1

About the scope of variables you can also find in documentation

  • What about the "Unexpected end"?

  • I do not understand much of the language, but it is the programming base that normally its "end" was used but the interpreter or compiler does not recognize that instruction at that particular point of the code, possibly caused by syntax error

Browser other questions tagged

You are not signed in. Login or sign up in order to post.