How to check for null references

Hans-Eric Grönlund hasse42g at gmail.com
Mon Aug 27 05:32:01 PDT 2007


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?

Best regards

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



More information about the Digitalmars-d mailing list