On Monday, 7 September 2015 at 14:26:57 UTC, mzfhhhh wrote:
On Monday, 7 September 2015 at 14:12:25 UTC, Bahman Movaqar wrote:
struct is a value type,you can convert to ref type by "ref":

    struct Test
    {
        int a;

        Test add1()
        {
            a++;
            return this;
        }
        ref Test add2()
        {
            a++;
            return this;
        }
    }

    Test t1;
    t1.add1.add1;
    writeln(t1.a);//1

    Test t2;
    t2.add2.add2;
    writeln(t2.a);//2

Thanks. I was afraid I had to resort to using pointers to achieve this!

Reply via email to