Hacker News new | ask | show | jobs
by mytochar 4080 days ago
Java's Runnable interface was an example of this in practice. Rather than passing a function, you passed an object whose primary purpose was to carry around a function that would be called.

   DoSomething(func() { ... })
becomes

   DoSomething(new Runnable() {
      public void run() { ... }
   });
or the longer form

   class MyAction implements Runnable {
      public void run() { ... }
   }

   DoSomething(new MyAction());