www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - struct opAssign in spec

reply "Red" <resmith lavabit.com> writes:
Looking at the Kindle spec there appears to be an error in the 
section for structs called Assignment Overload.

S* opAssign (ref const S s) {
    a = s.a;
}

gives an error:
Error: cannot implicitly convert expression (this) of type S to S*

S opAssign (ref const S s) {

does compile.
Dec 19 2012
parent =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 12/19/2012 09:57 PM, Red wrote:
 Looking at the Kindle spec
Here as well: http://dlang.org/struct.html#AssignOverload
 there appears to be an error in the section
 for structs called Assignment Overload.

 S* opAssign (ref const S s) {
 a = s.a;
Of course, there is also the return statement: return this;
 }

 gives an error:
 Error: cannot implicitly convert expression (this) of type S to S*

 S opAssign (ref const S s) {

 does compile.
You are right. The documentation is wrong. Ali
Dec 19 2012