Assignment not allow in while expression?


That’s exactly how I write my code, too. I call it the early-return convention. In this case it is early-break.

Explanation: reduce the number of nested structures (especially nested if), by introducing returns as early as possible.


Java 8 stream API could be useful


Use this kind of code.

val reader = BufferedReader(reader)
var line = 1

while (line != null) {
  line = reader.readLine()
  if(line != null)