delegate !is null
Steven Schveighoffer
schveiguy at yahoo.com
Fri Sep 4 12:04:26 PDT 2009
On Fri, 04 Sep 2009 14:33:12 -0400, Saaa <empty at needmail.com> wrote:
> 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?
Maybe you could rephrase your question in english. I can't really
understand what you are trying to do with this code.
i.e. "I want to be able to tell whether a delegate is null or not, how do
I do that". But you do that just like you said -- dg !is null.
-Steve
More information about the Digitalmars-d-learn
mailing list