Skip to content
New issue

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

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

Already on GitHub? # to your account

Change repeatN to support n=0 #3492

Merged
merged 1 commit into from
Oct 11, 2024
Merged

Change repeatN to support n=0 #3492

merged 1 commit into from
Oct 11, 2024

Conversation

L7R7
Copy link
Contributor

@L7R7 L7R7 commented Oct 11, 2024

While putting together a couple of simple Stream example, I was surprised that repeatN(0) fails with an error instead of completing with an empty Stream. I would have expected it to work as repeat.take(0) would do.

I'm opening this PR to get some feedback about this proposal. I'm happy to discuss possible consequences of this change.

Apart from avoiding surprises or confusion on the user side, I don't have any real use cases in mind where this would be necessary to have

This combinator now works equivalently to repeat.take(n)
@mpilquist mpilquist merged commit e54be00 into typelevel:main Oct 11, 2024
15 checks passed
@L7R7 L7R7 deleted the repeatN-zero branch October 11, 2024 12:04
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants