I don't get it. version(unittest) can't seem to use local variable

dysmondad via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jul 12 19:39:00 PDT 2014


On Saturday, 12 July 2014 at 05:23:29 UTC, Ali Çehreli wrote:
> On 07/11/2014 10:08 PM, dysmondad wrote:
>
> > class Velocity
> > {
>
> [...]
>
> >      ref Velocity opOpAssign(string op) ( in float multiplier
> )
>
> Unrelated to your question, you want to return just Velocity 
> there. Unlike C++, classes are reference types in D. So, 
> Velocity itself is essentially a Velocity* in C++.
>
> Ali

Right you are. I knew that but it still didn't translate into 
code. Thank you for pointing that out. I guess eventually I will 
remember that class variables are pointers.

As a point of curiosity, is the ref keyword in this case simply 
redundant or does it actually make a difference?


More information about the Digitalmars-d-learn mailing list