Yes: the variable does not live past the scope where it is defined. If you
want the value outside the loop, you should pre-declare the variable.

Also, you should take a close look at two parts of the manual (at least):
the performance section, and the "major differences from other languages"
section (includes matlab). Your code will be much slower than it could be,
because everything is being done in global scope.

On Mon, Oct 20, 2014 at 8:20 AM, Felipe Jiménez <[email protected]>
wrote:

> This is my first question here. I'm starting with Julia, so sorry if this
> is too simple.
>
> I am used to programming mostly in Matlab, so the following behavior has
> surprised me.
>
> I use the variable jjmin inside a for loop (not a function). After the
> loop finishes, its value is "forgotten"! Is this normal?
>
> Please find the file attached (you can run it or see its output commented
> at the end).
>
> Thank you in advance!
>
> F
>
>

Reply via email to