adrianfc
5/1/2020 - 8:51 AM

Loops

// Iterate through range of numbers
for (x in..5) {
  // 1,2,3,4,5
  print(x)
}

// Iterate through array
var friends = listOf("Ross", "Joey", "Chandler")
for (friend in friends) {
  // Ross  Joey Chandler
  print(friend)
}

// Run inner code twice
repeat(2) {
  println("A fish is swimming")
}