Skip to content

Instantly share code, notes, and snippets.

@ecstasy2
Created November 24, 2015 06:31
Show Gist options
  • Save ecstasy2/f117da27eb74d0875c6c to your computer and use it in GitHub Desktop.
Save ecstasy2/f117da27eb74d0875c6c to your computer and use it in GitHub Desktop.
public interface CmdFunction{
public void call(Object param);
}
// This is the function where you need a function passed in as a param
public void tellMeWhatTodo(CmdFunction cmd) {
if (something) {
cmd.call('me');
}
}
// Somewhere else
class MyClass {
var bar(){
}
void foo(){
// Now I am want to pass bar() to tellMeWhatTodo
tellMeWhatTodo(new CmdFunction(){
public void call(param) {
// Run some code
bar();
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment