Changing by ref a class passed in function

Zaher Dirkey via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jan 22 10:00:28 PST 2015


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 MyClass();
>     nullIt(o);

Template way is better here, thank you.



More information about the Digitalmars-d-learn mailing list