I have a simple method:
def process(element: SomeData): ZIO[Any, Nothing, Unit]
I would like to use it on every element from list:
def processElements(list: List[SomeData]): ZIO[Any, Nothing, Unit] = {
list.foreach(element =>
process(element)
)
}
And this method returns Unit
, so I added ZIO.succeed()
:
def processElements(list: List[SomeData]): ZIO[Any, Nothing, Unit] = {
ZIO.succeed(list.foreach(element =>
process(element)
))
}
I am not sure if it good approach to do it. Is it possible that this code will not be done or return errors? Is there better way to convert Unit
into ZIO[Any, Nothing, Unit]
?
Also I am not sure if this foreach
method is ok to use here, but I have no idea how I should process all elements from list in other way.