By Alvin Alexander. Last updated: August 1, 2024
In this ZIO performance tuning article by Pierre Ricadat, there’s this nice tip about using ZIO.foreachDiscard
instead of ZIO.foreach
:
“One of ZIO's common operators is ZIO.foreach
, which allows you to run an effect for each item in a collection. There's also ZIO.foreachDiscard
that is faster if you don't need to collect results (e.g., if your effect returns Unit
).”
For more details, see that article.