How to check for null references

Carlos Santander csantander619 at gmail.com
Mon Aug 27 05:40:00 PDT 2007


Hans-Eric Grönlund escribió:
> Hi all!
> 
> I'm trying to learn D, mostly by trial and error, and I keep tripping over
> the smallest rocks. This time the pebble is: How can I gracefully check if an
> object reference is null? I get an access violation if I try this and the
> reference (o) is null:
> 
> if (o == null) {...}
> 
> Is this a bug in DMD (I use the stable 1.x version) or did I miss something
> obvious?

Use:   if (o is null) {...}

> 
> Best regards
> 
> Hans-Eric Grönlund Software Developer, Project Manager, Freelance Journalist 
> http://www.hans-eric.com/

Since you're learning D, questions like this one are better suited for the 
D.learn newsgroup.

-- 
Carlos Santander Bernal



More information about the Digitalmars-d mailing list