Small suggestion for default constructors

Adam D Ruppe destructionator at gmail.com
Tue Jan 17 03:12:09 UTC 2023


On Tuesday, 17 January 2023 at 02:45:30 UTC, TheZipCreator wrote:
> 	default this(float x, float y, float z);

Try this out:

class Foo {
         int x;
         int y;
         int z;

         // one little function
         this(typeof(this.tupleof) t) {
                 this.tupleof = t;
         }
}

void main() {
         auto foo = new Foo(1, 2, 3);
         assert(foo.x == 1);
         assert(foo.y == 2);
         assert(foo.z == 3);
}


More information about the Digitalmars-d mailing list