News for hackers. Stuff that matters.
Re:Closures and Objects Are Equivalent by Rusky on Sunday April 12, 2015 @05:13PM (#9364749)
Pass an object to DoSomething and you get the same thing as the closure.
Re:Closures and Objects Are Equivalent by mytochar on Sunday April 12, 2015 @05:34PM (#9364816)
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());