Express "Class argument may not be null" ?

Johan Engelen via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Aug 8 11:34:54 PDT 2017


Hi all,
   How would you express the function interface intent that a 
reference to a class may not be null?
For a function "void foo(Klass)", calling "foo(null)" is valid. 
How do I express that that is invalid? (let's leave erroring with 
a compile error aside for now)

Something equivalent to C++'s pass by reference: "void 
foo(Klass&)".

(note: I mean D classes, for structs "ref" works)

Thanks,
   Johan



More information about the Digitalmars-d-learn mailing list