delegate !is null

Saaa empty at needmail.com
Fri Sep 4 11:33:12 PDT 2009


class C
{
  private int i;
  int method()
  {
    return i;
  }
}

class D
{
  private int delegate(void) _deleg;
  this(int delegate(void) d)
  {
    _deleg = d;
  }
  void write()
  {
    if(_deleg !is null)
    }
      writef(_deleg());
    }
  }
}
C c = null;
D d = new d;
d.function(c.method());
//This fails, as method is not availible for null.
d.function({return c.method();});
//This works but now I can't check whether c is null or not.
d.write(); //will fail.

Any suggestions? 




More information about the Digitalmars-d-learn mailing list