Skip to content

Some operators against empty collection should throw UnsupportedOperationException #167

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

Merged
merged 5 commits into from
Mar 23, 2021
Merged

Some operators against empty collection should throw UnsupportedOperationException #167

merged 5 commits into from
Mar 23, 2021

Conversation

xirc
Copy link
Contributor

@xirc xirc commented Mar 19, 2021

Closes the issue #137 😄

Operators below against empty collection should throw UnsupportedOperationException.

  • reduce
  • min
  • max
  • minBy
  • maxBy

We can see scala.collection.iterator.reduce throws UnsupportedOperationException if the collection is empty.
scala.collection.iterator#reduce

Changes

  • Nil.par.reduce throws UnsupportedOperationException.
  • Nil.par.min throws UnsupportedOperationException.
  • Nil.par.max throws UnsupportedOperationException.
  • Add a test whether Nil.par.minBy throws UnsupportedOperationException.
  • Add a test whether Nil.par.maxBy throws UnsupportedOperationException.

@xirc xirc marked this pull request as ready for review March 19, 2021 13:21
Base automatically changed from master to main March 22, 2021 19:28
@SethTisue
Copy link
Member

review by @scala/collections crew and/or by @axel22 ?

Copy link

@johnynek johnynek left a comment

Choose a reason for hiding this comment

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

Looks correct to me. Looks properly tested.

@SethTisue SethTisue merged commit 7bc6f6e into scala:main Mar 23, 2021
@SethTisue
Copy link
Member

thank you @xirc, @johnynek, and @NthPortal!

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.

4 participants