Assigning to class struct member leading to unexpected behavior.
Paul Backus
snarwin at gmail.com
Thu Jan 28 02:03:40 UTC 2021
On Thursday, 28 January 2021 at 01:43:13 UTC, Paul wrote:
> I'm experiencing a compile error, but for the life of me, I
> cannot figure out what is wrong.
>
> I'll try to keep it short but the code is roughly as follows:
>> class Window{
>> Screen screen;
>> alias screen this;
>>
>> this() {
>> Screen s = {bottom_f: {[0, 1]}};
>> this.screen = s; // Works
>> this.screen = {bottom_f: {[0, 1]}}; // Leads to the
>> list of errors below
>> }
The braced-initializer syntax only works in declarations, not
assignments.
Screen s = {bottom_f: {[0, 1]}}; // Ok - this is a declaration
this.screen = {bottom_f: {[0, 1]}}; // No good - this is an
assignment
More information about the Digitalmars-d-learn
mailing list