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

2.x defaultIfEmpty for Maybe #5417

Closed
uzzu opened this issue Jun 16, 2017 · 5 comments
Closed

2.x defaultIfEmpty for Maybe #5417

uzzu opened this issue Jun 16, 2017 · 5 comments

Comments

@uzzu
Copy link

uzzu commented Jun 16, 2017

Hi. I'm glad that I started using 2.x and be able to use Maybe.
I started using it, and wanted to ask a question.

Now Maybe#defaultIfEmpty returns Maybe, but because this operator guarantees to emit data, I think should be Maybe#defaultIfEmpty returns Single.

I would like to know if there is a reason to return Maybe.

@akarnokd
Copy link
Member

It was probably overlooked but we can't change the type now.

@vanniktech
Copy link
Collaborator

defaultIfEmptySingle that returns Single?

@akarnokd
Copy link
Member

There is the toSingle(T defaultValue).

@akarnokd
Copy link
Member

Also defaultIfEmpty is based on switchIfEmpty thus it returns Maybe.

@uzzu
Copy link
Author

uzzu commented Jun 16, 2017

OK. 👍
I write unit tests and it seems that there is no problem with substituting toSingle(T defaultValue), so I will use that.

[IMO] I think that defaultIfEmpty is more readable than toSingle , so I'd like to return Single in 3.x or future versions.

Thank you for answering my question 😄

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

3 participants