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

Adding orNull #1414

Merged
merged 1 commit into from
Apr 30, 2020
Merged

Adding orNull #1414

merged 1 commit into from
Apr 30, 2020

Conversation

sksamuel
Copy link
Member

No description provided.

fun <A> Arb<A>.orNull(): Arb<A?> = arb(this.edgecases().plus(null as A?)) { rs ->
sequence {
while (true)
yield(if (rs.random.nextBoolean()) null else this@orNull.next(rs))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

every other value from the arb will be a null.
Should we consider a more realistic scenario and reduce the amount of nulls generated?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had a similar discussion on slack

@sksamuel
Copy link
Member Author

Nice.

@sksamuel sksamuel mentioned this pull request Jun 7, 2020
33 tasks
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

Successfully merging this pull request may close these issues.

2 participants