MarioAriasC/funKTionale

Option.empty like Scala

toyamah opened this issue · 4 comments

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

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

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>.

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

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

Fix on 1.2