opAssign return type

Q. Schroll via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Sep 2 10:18:15 PDT 2016


When overloading assignment, I've been taught in my C++ course to 
return a reference to the lvalue being assigned to. This is 
easily possible in D, but in Phobos it is used rarely and in Ali 
Çehreli's Book it is neither taught to do so.

Is there any reason to it? To me it seems very obvious to do it 
like in C++.

The question came up in the discussion of a PR:
https://github.com/dlang/dlang.org/pull/1466


More information about the Digitalmars-d-learn mailing list