-
Notifications
You must be signed in to change notification settings - Fork 111
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
Improve implicit convertion #195
Comments
Actually, the Java compiler doesn't infer the correct type. It just thinks that
and it cannot be compiled. I'm not sure how the Scala compiler works. But maybe the Scala compiler behavior is better as it refuses to use a wrong type in such case. |
Thanks @zsxwing for pointing out that Observable.<Integer>create(s -> s.onNext(0))
.subscribe(i -> System.out.println(i + 1)); So But Anyway we could improve that? |
The problem is that in order to translate a Java program doing
So you can write your example in Scala as follows: Observable.apply[Int](s => s.onNext(1))
.subscribe(println(_)) or equivalently Observable((s: Subscriber[Int]) => s.onNext(1))
.subscribe(println(_)) The I agree that this is confusing and should be improved, thank you for pointing it out. I suggested to change this here. |
Closing this since Observable.create has been deprecated in #196 |
The following Scala code won't compile
While the same thing in Java works fine.
Also, in the following compilable version, we shouldn't have to explicit add
Int
as the type param;Edit
Remove the redundant call to
Scheduers.newThread()
in the last snippet. That's related to another issues I reported to Jetbrains (you can find it here).The text was updated successfully, but these errors were encountered: