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

Provide Seq(..).maxOption and friends #6574

Merged
merged 1 commit into from
May 2, 2018

Conversation

stephennancekivell
Copy link
Contributor

Provide Seq(..).maxOption and friends so developers can easily write code that handles the empty case.

@scala-jenkins scala-jenkins added this to the 2.13.0-M4 milestone Apr 28, 2018
@stephennancekivell
Copy link
Contributor Author

Just signed the cla. Please validate again. :)

@SethTisue
Copy link
Member

[test] [error] /home/jenkins/workspace/scala-2.13.x-validate-main@2/test/junit/scala/collection/TraversableOnceTest.scala:81: diverging implicit expansion for type scala.math.Ordering[T1]
[test] [error] starting with object Int in object Ordering
[test] [error]     assert(Nil.maxOption == None, "maxOption on a Empty Iterable is None")
[test] [error]                ^
[test] [error] /home/jenkins/workspace/scala-2.13.x-validate-main@2/test/junit/scala/collection/TraversableOnceTest.scala:82: diverging implicit expansion for type scala.math.Ordering[T1]
[test] [error] starting with object Int in object Ordering
[test] [error]     assert(Nil.minOption == None, "minOption on a Empty Iterable is None")
[test] [error]                ^
[test] [error] /home/jenkins/workspace/scala-2.13.x-validate-main@2/test/junit/scala/collection/TraversableOnceTest.scala:83: diverging implicit expansion for type scala.math.Ordering[T1]
[test] [error] starting with object Int in object Ordering
[test] [error]     assert(Nil.maxByOption(identity) == None, "maxByOption on a Empty Iterable is None")
[test] [error]                           ^
[test] [error] /home/jenkins/workspace/scala-2.13.x-validate-main@2/test/junit/scala/collection/TraversableOnceTest.scala:84: diverging implicit expansion for type scala.math.Ordering[T1]
[test] [error] starting with object Int in object Ordering
[test] [error]     assert(Nil.minByOption(identity) == None, "minByOption on a Empty Iterable is None")
[test] [error]                           ^
[test] [error] four errors found

@stephennancekivell
Copy link
Contributor Author

Oh my, thanks Seth. Funny I dont get that when I run from idea. Anyway fixed and updated.


@Test
def checkNonEmptyOption: Unit = {
assert(Seq(1).maxOption == Some(1), "maxOption on a Empty Iterable has option")

Choose a reason for hiding this comment

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

on a Empty Iterable ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opps, sorry thanks, fixed.

@stephennancekivell stephennancekivell changed the title provide minOption and maxOption Provide Seq(..).maxOption and friends Apr 29, 2018
Copy link
Member

@szeiger szeiger left a comment

Choose a reason for hiding this comment

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

Looks like a useful addition to me.

@szeiger szeiger merged commit 698ec6b into scala:2.13.x May 2, 2018
@SethTisue
Copy link
Member

thanks @stephennancekivell! this is now your little patch of land in the Scala standard library :-)

@stephennancekivell stephennancekivell deleted the safe-min-max branch May 3, 2018 11:29
@stephennancekivell
Copy link
Contributor Author

haha, thanks @SethTisue

@SethTisue SethTisue added the release-notes worth highlighting in next release notes label May 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes worth highlighting in next release notes
Projects
None yet
5 participants