Do-While 循环

var line = 0
var maximum_lines = 5

do {
  line = line + 1
  println("Line number: " + line)
} while (line < maximum_lines)

do / while 循环在函数式编程中很少使用,但可以用来解决对 break / continue 结构缺乏支持的问题,如其他语言所示:

if(initial_condition) do if(filter) {
  ...
} while(continuation_condition)