-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
add methods to Left and Right for upcasting the other type parameter #7011
Conversation
anyone have a better idea for the method name? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @jozic!
Is this worth having for |
@NthPortal |
@jozic good point |
If anyone has a better idea for the method name, please send a PR. 😄 |
thanks @dwijnand |
gah I hate the name pleased to have this landing, regardless |
I guess coming up with that will be |
|
maybe |
|
I would call it |
That would work really well if, given Either is right-biased, it had a companion object Either("foo").or[Int] |
another possibility, based on @smarter's suggestion, might be |
how about the issue with |
since M5 is imminent, I'm going to make an executive decision here and (for M5, anyway) go with @jozic's suggestion of justification: if we expected this to be very commonly used, as for |
This is another implementation of #6328 and #6329
based on suggestion by @lrytz
motivation:
Left
andRight
constructors are typed asLeft
andRight
respectively, but sometimes we want something likeOption.empty
which returnsNone
but typed asOption
.The test represents a code that would not compile if plain
Left
/Right
constructors are used@SethTisue @lrytz please check it again, thanks!
EDIT: updated in #7080 to name the methods
withLeft
andwithRight