Can someone please tell me if there is an equivalent for Python\'s lambda functions in Java?
Somewhat similarly to Zifre's, you could create an interface thus
public interface myLambda {
Out call(In i);
}
to enable you to write, say
Function func = new Function() {
public Boolean callFor(myObj obj) {
return obj.canDoStuff();
};
MyObj thing = getThing;
if (func.callFor(thing)) {
doSomeStuff();
} else {
doOtherStuff();
}
It's still a bit kludgy, yeah, but it has input/output at least.