Is there anyway I could get: ``` CompletableFuture...
# getting-started
p
Is there anyway I could get:
Copy code
CompletableFuture<List<Person>>
from
Copy code
List<CompletableFuture<Person>>
I can't wrap my head around it 😕
stackoverflow 1
r
According to stackoverflow (https://stackoverflow.com/questions/30025428/listfuture-to-futurelist-sequence), you can use a function like this:
Copy code
fun <T> List<CompletableFuture<T>>.unwrap(): CompletableFuture<List<T>> =
    CompletableFuture.allOf(*toTypedArray()).thenApply { map { it.join() } }
Basically, it creates a wrapper
CompletableFuture
that waits for all the others to finish, then unwraps each value into a list.
p
interesting.. thank you, hopefully the dispatcher will be happy with this
👍 1
d
holds up "Monads" flag
k
Cries while attempting to learn monads
c
Cries over the memory of skipping over the monads question in my university exam