Iterating the elements of a Gosu array

In Gosu, you can iterate through the elements of an array in a for loop. You declare a temporary iteration variable to hold an element of the array during each loop iteration, and you specify the name of the array through which to iterate. The following code declares the iteration variable element and then uses it to print each element of the array.

var stringArray = new String[] {"one", "two", "three", "four"} 

for (element in stringArray) {
  print(element) 
}

The output from this code is:

one
two
three
four

See also