Best way to make simple callback
I'm in doubt of how works Java. I need do a code like it (in PHP):
开发者_运维技巧array_map(function($object){ ... });
And on Java, I close to it:
this.addTransition(new CallerTransition() {
@Override
protected void execute() {
// Do something with _this_ here
}
});
Translating: I need know if exists a better way to work with closures-like.
Notes: CallerTransition
is subtyped Transition
. addTransition requires a Transition
. The execute
method will be executed by addTransition
.
Java doesn't have lambda functions or function-based closures, so I'm afraid anonymous classes are the best way to go.
精彩评论