1. Generator
can simplify callback-style functions. For example, readLines() function takes a closure called for each line. With generator, the same thing can be written in for-statement.
// callback-style
readLines("/etc/passwd", function (i) println(i))
// with generator
for (i : readLines("/etc/passwd")){
println(i)
}
The following functions can also be simplified using generator.