for and foreach - Squeng/Polyglot GitHub Wiki

Scala has for statements, for expressions, and Scala collections have a foreach method. Furthermore, Scala is getting even better fors.

val woerter = Seq("the", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog")

for wort <- woerter do
  println(wort)

woerter.foreach(println)

Java has (enhancecd) for statements and Java Streams have a forEach method.

var woerter = List.of("the", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog");

for (var wort : woerter) {
    System.out.println(wort);
}

woerter.stream().forEach(System.out::println);

Python has for statements.

woerter = ['the', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog']

for wort in woerter:
    print(wort)