Skip to content

Instantly share code, notes, and snippets.

@mattumotu
Created November 14, 2018 10:09
Show Gist options
  • Save mattumotu/a220f870ca81ed1f3b32e37f6bd6be33 to your computer and use it in GitHub Desktop.
Save mattumotu/a220f870ca81ed1f3b32e37f6bd6be33 to your computer and use it in GitHub Desktop.
// Generic example
public void myMethod(myDelegate paramName) { ... }
// encapsulate matchingMethod1 in myDelegate and pass into myMethod
myMethod(new myDelegate(matchingMethod1));
// alternative syntax for matchingMethod2
myMethod(matchingMethod2);
// Concrete example
public void borrowStapler(responseBehaviour lateResponse) { ... }
// encapsulate askPolitely in responseBehaviour delegate and pass into borrowStapler
borrowStapler(new responseBehaviour(askPolitely));
// alternative syntax for theLastStraw
borrowStapler(theLastStraw);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment