delegate !is null

Steven Schveighoffer schveiguy at yahoo.com
Tue Sep 8 05:03:58 PDT 2009


On Sun, 06 Sep 2009 18:54:47 -0400, Saaa <empty at needmail.com> wrote:

> I'd like to set D's delegate to a method which is not yet available (like
> c.method).
> I solved this by encapsulating the method within a function literal, but  
> I
> also need to know whether
> the method is available or not when calling the delegate.
> I could do this by making the function literal include the null-checking
> code, but is there maybe a better solution to this problem?
> The delegate is supposed to change a variable within the D class.
> Hope you understand it :)

A delegate is a struct with a data pointer and a function pointer.  You  
can access the individual parts via .ptr and .func (I believe).  You can  
even change them via those properties.

does that help?

-Steve


More information about the Digitalmars-d-learn mailing list