The for loop can also be used to loop through List and Set as well, as follows:
var letters = stringFormatter.csvToList("A,B,C,D,E,F,G,H,I");
if (letters != null) {
for (letter in letters) {
var word : String = when(letter) {
"A" -> "Apple";
"B" -> "Ball";
"C" -> "Cat";
"D" -> "Dog";
else -> "Don't Know";
}
println("$letter for $word");
}
}
Here, the letters variable is a List of strings objects.