The do…while loops

The do…while loop is similar to the while loop, with the exception that in the conditional test for the reiteration of the loop, it is carried out after the first iteration. It takes the following form:

do {  ...} while (condition) 

The statements within the block are executed while the condition tested holds true:

var i = 0do { println("I’m in here!") i++} while (i < 10)println("I’m out here!")

Nullable valuesThe NullPointerException is one thing that individuals who have first-hand experience writing Java code are certain to have encountered. The Kotlin type system is null-safe—it attempts to eliminate the occurrence of null references within code. As a result, Kotlin possesses nullable types and non-nullable types ...

Get Kotlin Programming By Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.