Skip to content
Frederic Jarjour edited this page May 21, 2022 · 3 revisions

For loops

In Kode, for loops do not have a built in counting variable. Instead, the user must set it up themselves. Here is an example of a for loop in Kode:

int i = 0
for i < 10
    print(i)
    i = i + 1
end for

Looping over an array

One very useful application of the for loop is to loop over the values of an array. Here is an example of a for loop that prints the values in an array:

val array = [1, 2, 3]

int i = 0
for i < len(array)
    print(array[i])
    i = i + 1
end for
Clone this wiki locally