Skip to content

Instantly share code, notes, and snippets.

@jartur
Created June 25, 2012 15:37
Show Gist options
  • Save jartur/2989312 to your computer and use it in GitHub Desktop.
Save jartur/2989312 to your computer and use it in GitHub Desktop.
java8 lambda overloading example
public class Wewe {
interface A {
int run(int x);
}
interface B {
int run(String x);
}
private void overloaded(A a)
{
a.run(1);
}
private void overloaded(B b)
{
b.run("1");
}
private void a()
{
overloaded(x -> {return 1;});
// error: reference to overloaded is ambiguous, both method overloaded(A) in Wewe and method overloaded(B) in Wewe match
overloaded((A)x -> {return 1;});
// OK
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment