question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 and Observable::empty to anonymous classes

Can you elaborate?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:15 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
benjchristensencommented, Oct 13, 2014

I’m considering this “as good as it can get” then since our flatMap matches the Stream interface definition:

<R> Observable<R> flatMap(Func1<? super T, ? extends Observable<? extends R>> func)

Thanks @akarnokd for the insight.

0reactions
akarnokdcommented, Oct 13, 2014

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:

<R> Stream<R> flatMap(Function<? super T,? extends Stream<? extends R>> mapper)

So it is either lambda workarounds for Java 8 devs or unchecked casting for Java 6/7 to bypass the lack of variance.

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found