Changing by ref a class passed in function
Zaher Dirkey via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jan 22 05:06:40 PST 2015
See example bellow, i want to pass object to function nullIt and
want this function to null it.
----
import std.stdio;
static if (!is(typeof(writeln)))
alias writefln writeln;
class MyClass{
}
void nullIt(ref Object o)
{
o = null;
}
void main()
{
auto o = new MyClass();
nullIt(o);
if (o is null)
writeln("It is null");
}
Thanks in advance.
More information about the Digitalmars-d-learn
mailing list