Re: Changing by ref a class passed in function

2015-01-22 Thread Zaher Dirkey via Digitalmars-d-learn
On Thursday, 22 January 2015 at 14:39:45 UTC, anonymous wrote: On Thursday, 22 January 2015 at 14:29:59 UTC, anonymous wrote: o needs to be typed as Object: Object o = new MyClass(); nullIt(o); Alternatively, templatize nullIt: void nullIt(O)(ref O o) {o = null;} auto o = new M

Re: Changing by ref a class passed in function

2015-01-22 Thread anonymous via Digitalmars-d-learn
On Thursday, 22 January 2015 at 14:29:59 UTC, anonymous wrote: o needs to be typed as Object: Object o = new MyClass(); nullIt(o); Alternatively, templatize nullIt: void nullIt(O)(ref O o) {o = null;} auto o = new MyClass(); nullIt(o);

Re: Changing by ref a class passed in function

2015-01-22 Thread anonymous via Digitalmars-d-learn
On Thursday, 22 January 2015 at 13:06:42 UTC, Zaher Dirkey wrote: 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

Changing by ref a class passed in function

2015-01-22 Thread Zaher Dirkey via Digitalmars-d-learn
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 = ne