opAssign() still accepted for classes???
Steven Schveighoffer
schveiguy at yahoo.com
Fri Apr 29 10:54:47 PDT 2011
On Fri, 29 Apr 2011 13:49:19 -0400, KennyTM~ <kennytm at gmail.com> wrote:
> Though this isn't valid with a 'struct'.
>
> ------------------------
> import std.stdio;
> struct K {
> K opAssign(int x) {
> writeln(x);
> return this;
> }
> }
> void main() {
> // K k = 8; // Error: cannot implicitly convert expression (8) of
> type int to K
> K k;
> k = 8; // OK.
> }
> ------------------------
Interesting! So this is definitely an inconsistency that indicates the
class version is a bug.
-Steve
More information about the Digitalmars-d
mailing list