Anonymous classes
You are here :

Sub nodes

Recent changes
Site plan

Anonymous classes are a way to quickly implements an interface. This is the mean to implement callback in Java. In Nosica, as we will have signal and slots this will allow someone to define richer callback.

Syntax :

 new Interface(Arguments) {
   // interface implementation

Example :

 public interface SomeInterface {
   int f(SomeObject o);
 public class SomeClass {
   private int i;
   public sub h(SomeInterface si)
     Console.out << si.f(new SomeObject(1)) << "\n";
   public sub g()
       new SomeInterface() {
         public int f(SomeObject o)
           return i * o.getValue();

Instead of using an anonymous class you can use an inner class.

Propulsed by Wiclear