I seem to have a generic problem: if one user-created class is meant to contain an instance of another user created class, it can't be assigned. A blank member instance is created whenever the containing class is instantiated, but no matter what I've tried, it can't ever be replaced.
Obviously, there are better ways to accomplish this particular task, but when what I want to program follows something like a functional paradigm (java users will think of the ubiquitous Runnable interface), this really is the best way to test.
Code:
: mata clear : class Inner { > void speak() > string scalar toSay > void new() > } : void Inner::new() { > "creating inner instance" > } : void Inner::speak() { > this.toSay > } : class Outer { > class Inner scalar i > void speak() > void setInner() > } : void Outer::speak() { > this.i.speak() > } : void Outer::setInner(class Inner inner) { > this.i = inner > } : : inner = Inner() creating inner instance : inner.toSay = "hello!" : inner.speak() hello! : outer = Outer() creating inner instance : outer.setInner(inner) creating inner instance Outer::setInner(): 3011 invalid lval <istmt>: - function returned error
Comment