I'm trying to simplify my object creation with lamdas.
I have a class that provides the public void addCmd(ScriptCommand cmd)
-method.
With this I can write a call like this:
ScriptCommand cmd = new ScriptCommand() {
@Override
public void run(double deltaTime) {
// some logic here...
}
};
addCmd(cmd);
I've already tried to call something like this:
ScriptCommand cmd = (deltaTime) -> {
// some logic here...
};
addCmd(cmd);
However, this is recognized as an error by the IDE. How do you use lambdas in such a case?
EDIT:
ScriptCommand
looks like that:
public abstract class ScriptCommand {
private boolean completed = false;
public abstract void run(double deltaTime);
protected void complete() {
completed = true;
}
public boolean isCompleted() {
return completed;
}
}