Let's say we have two classes, A and B. The latter has a dynamic array of X and type X has an add() method that can be used to append elements (of type C, another struct) to X's own dynamic array of C. So it's something like the following:
struct C {}
struct X { C[] cs;
void add(C c) { cs ~= c; }
}
class A {
X x;
void mfd(ref B b) {
// manipulate A.x and one B.xs (returned by B.x1()
// by calling another member function
// that calls X.add(some C)
}
}
class B {
X[] xs;
this() { xs.length = 1; }
ref X x1() { return xs[0]; }
}
After A and B are instantiated and A.mfd() is called, the changes to A.x are visible in main. However, although the changes to the X returned by B.x1() are visible while A.mfd() executes, the B.xs[0] is unchanged after it returns.
My understanding was that since A, B and X[] are all reference types, this ought to work, but obviously something is missing.