Created
May 14, 2017 11:59
-
-
Save stevenschwenke/f7470fc434e3d334436d2c22f05d7f17 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@FunctionalInterface | |
public interface SimpleFunctionalInterface { | |
public int returnAnswerToUltimateQuestion(); | |
} | |
@Test | |
public void normalInterfaceOnlyOneAbstractMethod() { | |
int x = 1; | |
SimpleFunctionalInterface myInterfaceImpl = () -> { | |
// x = 2; // impossible | |
instanz = 3; // possible because member variables are copied when creating lambdas. (http://stackoverflow.com/questions/25055392/lambdas-local-variables-need-final-instance-variables-dont) | |
// TODO: Why is the class, in which the lambda is defined, copied? I thought that lambdas are "closed" definitions of functionality that can be passed around. | |
return 0; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks a lot! Changed my workshop accordingly. Could you please have a look at this commit? It should contain everything important, but a review would be nice. :)