I have a ton of classes with one method (half of them don't use their parameter and thus name it underscore), and I just switched to Java 8. Now I want to replace them with lambdas.
Here is my code:
interface I {
void stuffHappened(Integer howManyStuff);
}
public class A {
void go() {
I i = new I() {
public void stuffHappened(Integer _) {
System.out.println("woah!!");
}
};
}
}
And after:
interface I {
void stuffHappened(Integer howManyStuff);
}
public class A {
void go() {
I i = _ -> System.out.println("woah!!");
}
}
As you can see, it is apparently no longer valid, claiming the use of "_" as the parameter name is no longer valid. But then why did it allow this refactor in the first place? And why does it work with anonymous classes, but not lambdas? Is this really a new rule? Or is it some sort of discrepancy in IDEA?
I'm using Intellij-IDEA (first time using it), well actually, Android Studio (Beta) 0.8.1 (using retrolambda to permit lambdas on android), which I think uses IDEA.