mergeMap/flatMap and Java 8 type inference
See original GitHub issue@adelnizamutdinov I don’t see a new issue created, so wanted to pick it up here.
You said this:
mergeMap is almost unusable with Java 8 type inference Always have to extend
Observable::just
andObservable::empty
to anonymous classes
Can you elaborate?
Issue Analytics
- State:
- Created 9 years ago
- Comments:15 (12 by maintainers)
Top Results From Across the Web
Java 8 Type Inference improvements - W3schools.blog
Type Interface feature was introduced in Java 7 which provides ability to compiler to infer the type of generic instance. We can replace...
Read more >Type Inference - Learning the Java Language
Type inference is a Java compiler's ability to look at each method invocation and corresponding declaration to determine the type argument (or arguments) ......
Read more >Why does the Java 8 generic type inference pick this overload?
The rules of type inference have received a significant overhaul in Java 8; most notably target type inference has been much improved.
Read more >Java 8 Type Inference - Javatpoint
Type inference is a feature of Java which provides ability to compiler to look at each method invocation and corresponding declaration to determine...
Read more >Java 8 Lambda Basics 10 - Type Inference - YouTube
Access the full course here: https://javabrains.io/courses/java_lambdabasics Learn how the Java compiler and runtime infers type information ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m considering this “as good as it can get” then since our
flatMap
matches the Stream interface definition:Thanks @akarnokd for the insight.
Java 6 and 7 developers would need the full covariance in the parameter types and only Java 8 non-Eclipse developers have to do workarounds such as above. Besides, the Stream.flatMap has full covariance in its signature:
So it is either lambda workarounds for Java 8 devs or unchecked casting for Java 6/7 to bypass the lack of variance.