Confused about referencing in D

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jul 14 05:18:48 PDT 2016


On Thursday, 14 July 2016 at 06:23:15 UTC, Gorge Jingale wrote:
> I think that the assignment in the first case is not assigning 
> the reference returned by auto ref GetValue().


`ref` in D is shallow, it only applies to the thing it is 
specifically on and is lost across assignments. Once you assign a 
ref to a new variable, it isn't ref anymore.

> I am expecting it to work like a pointer,

If you need a pointer, use a pointer! ref is a different thing.


More information about the Digitalmars-d-learn mailing list