y
03/12/2023, 1:48 PMclass Foo {
val seq: Sequence<Bar> = //...
fun process() {
for (elem in seq) {
// do something with elem,
// but maybe throw an exception
}
}
}
is it sound to call process()
again if an exception is thrown? will the sequence continue from the element immediately after the element for which the exception was thrown?CLOVIS
03/12/2023, 2:08 PMy
03/12/2023, 2:11 PMCLOVIS
03/12/2023, 2:12 PMy
03/12/2023, 2:18 PMprocess()
function in a loop that keeps retrying the function until seq
is exhausted. the catch
block of the wrapping function does something with the caught exceptions.process
should take the next yielded value