https://kotlinlang.org logo
Title
d

dr.dreigh

04/26/2020, 9:05 PM
yeah - it's very nully as it stands. Those are great ideas, thanks, I'll have a play tomorrow.
👍🏻 1
l

LeoColman

04/28/2020, 8:13 PM
I would also suggest an overload to it with a double chance
fun <A> Arb<A>.orNull(nullChance: Double = 0.25): Arb<A?>
s

sam

04/28/2020, 8:20 PM
That's fine, it can pass a function to the other of
{ it.random.nextDouble() < nullChange }
d

dr.dreigh

04/30/2020, 7:33 AM
I've actually done both, I'm close to being done - just putting some docs/kdoc, will submit a PR tonight, happily remove either version though. In our codebase we use orNull() a lot with the old kotlintest to replicate the input from another system being null, and I can see us using (
orNull(0.25)
a lot, but that's not to say that version of the function needs to exist in Kotest, it'd happily live in our code)
s

sam

04/30/2020, 1:20 PM
Sounds good
d

dr.dreigh

04/30/2020, 4:07 PM
Just pushed to the branch/ PR: https://github.com/kotest/kotest/pull/1414
👍🏻 1