The while loop

The while loops are a way to iterate while a condition is being satisfied and are crucial in situations where a for loop will not fit. The syntax for a while loop is similar to Java and is shown as follows:

var animals = arrayOf("Cat", "Lion");

var index = 0;
while (index < animals.size) {
var animal = animals[index++];
println("This animal is a $animal");
}

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.25.217