better-monadic-for
better-monadic-for copied to clipboard
For-comp with no yield should use .foreach
reproduction steps
Desugar the following:
for {x <- List(1); y = 1} ()
problem
It effectively desugars to:
List(1).map { x => val y = 1; (x, y) }.foreach { case (x, y) => () }
expectation
Because there's no yield
, I expect all .flatMap
and .map
calls to be .foreach
instead. It should desugar to:
List(1).foreach { x => val y = 1; () }