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

isEqual should be added to Option as convenience method #6064

Closed
scabug opened this issue Jul 11, 2012 · 8 comments
Closed

isEqual should be added to Option as convenience method #6064

scabug opened this issue Jul 11, 2012 · 8 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Jul 11, 2012

isEqual should be added to Option as a convenience method in order to compare a value with the value contained in an Option

def isEqual(other: Any): Boolean

so that you can write

Some(123) isEqual 123 = true

You can't use equals, because the other value is no option. This is a pure convenience method, one can do something like:

-Some(123).getOrElse(false) equals 123
-Some(123).exists(_ equals 123)

this should be a very easy addition.

@scabug
Copy link
Author

scabug commented Jul 11, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6064?orig=1
Reporter: Otto (otto5)

@scabug
Copy link
Author

scabug commented Jul 11, 2012

@SethTisue said:
I would just write this as:

myOption == Some(123)

@scabug
Copy link
Author

scabug commented Jul 11, 2012

Otto (otto5) said:
Obviously this issue is not a Blocker, but JIRA didn't allow me to change the priority field. Sorry.

@scabug
Copy link
Author

scabug commented Jul 11, 2012

@soc said:
I wanted to say “Well, why don't you use contains?” ... but ... it is missing?!

Is there and reason for Option missing contains, considering that its API is pretty much identical to the collections API?

I guess this is an oversight and should be fixed.

@scabug
Copy link
Author

scabug commented Jul 11, 2012

Otto (otto5) said:
You are right, contains would be an option as well.

@scabug
Copy link
Author

scabug commented Jul 11, 2012

@soc said:
scala/scala#886

@scabug
Copy link
Author

scabug commented Aug 4, 2012

@adriaanm said:
scala/scala#1007

@scabug scabug closed this as completed Aug 4, 2012
@scabug
Copy link
Author

scabug commented Aug 4, 2012

@soc said:
Hi Otto,

thanks for your bug report! It made us aware that the contains method was missing ... surprising how long nobody realized it. :-)

Sadly, the deadline for adding it to Scala 2.10 was missed by a week, but as you see, the method was already added and will appear in 2.11.

@scabug scabug added this to the 2.11.0-M1 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants