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

Option.empty like Scala #27

Closed
toyamah opened this issue Apr 14, 2017 · 4 comments
Closed

Option.empty like Scala #27

toyamah opened this issue Apr 14, 2017 · 4 comments
Assignees

Comments

@toyamah
Copy link

toyamah commented Apr 14, 2017

Hi there.
Is there a method which returns Option.None like Scala.
I tried to find the method but I couldn't.

@MarioAriasC
Copy link
Owner

No, there isn't. What is your use case? You could access None directly.

@toyamah
Copy link
Author

toyamah commented Apr 15, 2017

Thank you for reply.

My use case is,
when I use funKTionale with RxJava, I'd like to know a network error if accessing web API is failed.

    val networkError: Observable<Option<Throwable>> = Observable.fromIterable(1..4)
        .flatMap { page -> webApi.postData(page) }
        .map { Option.empty<Throwable>() }
        // .map { None  } if it is used, returned type is changed to None instead of Option<Throwable>
        .onErrorReturn { networkError -> networkError.toOption() }

If I use None directly, the type is changed to None instead Option<Throwable>.
That' why I should cast the type.

But if I can use Option.empty<Throwable>, then the type is changed to Option<Throwable>.

@MarioAriasC
Copy link
Owner

Ok, I think we could include that in a future release. Not sure about naming.

Additionally, you could rise a PR, if you want.

@MarioAriasC MarioAriasC self-assigned this Apr 29, 2017
@MarioAriasC
Copy link
Owner

Fix on 1.2

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

No branches or pull requests

2 participants