Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zipOrAccumulate with two procedures executes each procedure twice. #111

Closed
rhirai-line opened this issue Oct 28, 2024 · 0 comments
Closed

Comments

@rhirai-line
Copy link

rhirai-line commented Oct 28, 2024

Hello.

I'm using zipOrAccumulate with two procedures.
Then I faced the problem that each procedure is executed twice.
I would like to avoid this behavior because my procedure calls an external API.

I think that this behavior is caused by the following code.

Therefore, I would appreciate it if you could correct it as follows.

diff --git a/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Zip.kt b/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Zip.kt
index 9dbb864..c6e2809 100644
--- a/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Zip.kt
+++ b/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Zip.kt
@@ -144,8 +144,8 @@ public inline fun <T1, T2, E, V> zipOrAccumulate(
     val result1 = producer1()
     val result2 = producer2()
 
     val results = listOf(
-        producer1(),
-        producer2(),
+        result1,
+        result2,
     )
@rhirai-line rhirai-line changed the title zipOrAccumulate which provides two procedures executes each procedure twice. zipOrAccumulate with two procedures executes each procedure twice. Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant