Overview for loops

Global variables within loop in Julia

Julia has unusial definition of global variables within loop cycles.

For example, in other languages, it's possible to use outer variable and change it inside for-loop construction (JavaScrip code):

JavaScript code

var i;
for (i = 0;i < 12;i++) {
  i+=1;
} 
console.log(i);

This code will result in:

12

Python code

y = 0;
for x in range(0,5):
    y += 1

print(y)

output:

5

Read more

Written by Administrator on Thursday May 14, 2020