I just posted this question at the bottom of the 1...
# stdlib
a
I just posted this question at the bottom of the 1.1 blog post: What is the reasoning behind creating
onEach()
? What does this give a developer that you can’t get from
forEach()
? I don’t think it is clear to a new developer to the language that calling
onEach()
returns the iterable instance for the next statement in the chain. In the example above I would just call
forEach()
in the following way:
Copy code
.forEach { f ->
  println(“Moving $f to $outputDir”)
  moveFile(f, File(outputDir, f.toRelativeString(inputDir)))
}