https://kotlinlang.org logo
Title
a

Andrew Gazelka

04/16/2018, 5:16 PM
let's say I have 10_000 test cases which map to a float
result
. I want to quickly find a test case, where
result < c
, where
c
is a constant. Is there any way I can cleanly structure my code to achieve this?
the way I do this now is just with a
var done: Boolean
variable, where each coroutine skips if
done
is true. Is this good structure?
b

bj0

04/16/2018, 5:39 PM
you can just use cancellation
a

Andrew Gazelka

04/16/2018, 5:55 PM
hmm I guess the biggest problem I am facing is there are several Jobs, but only one is going to return a value that will be used... is there a clean way to do this?
b

bj0

04/16/2018, 5:56 PM
depends on what you're doing, you could use a channel to push the result(s), or select
a

Andrew Gazelka

04/16/2018, 5:57 PM
ok, thanks
@bj0 the problem I am running into is still giving a result if none of the test case results are in the tolerance (i.e. return
None
)
so I would need to detect when all the
launch{}
Jobs are finished
b

bj0

04/16/2018, 6:37 PM
you can
join
on them
👍 1