Chaining struct method invocations

Jacob Carlborg via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Sep 7 07:54:03 PDT 2015


On 2015-09-07 16:44, Bahman Movaqar wrote:

> Does this mean that in the following piece of code, what is passed to
> `add` is actually a copy of `rec1`?
>
>     auto rec1 = SalesRecord("p10", 1.0, 10);
>     coll.add(rec1);

Yes. structs have value semantics. If you want reference semantics you 
might want to use a class instead.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list