In order to avoid overwriting the object when the property of that object gets an update, the output object only needs to be constructed when it doesn't exist in the caller workspace.
function zo = update(obj, zi)% obj is an object of a class; while zi & zo are objects of the same class
% different than obj.
if ~exist(zo) % if zo doesn't exist already in parent workspace
zo = const(); % construct object zo
end zo = func(zi) end
In the parent workspace, responding to an event of A, an object Y updates its property based on object X.
Y = A.update(X)
So, inside the function (method) definition, the line
if ~exist(zo)
should have been
if ~exist(Y)
How do I know what name (like "Y") the user have assigned "zo" to from within function "update"? In another word, I'm looking for the equivalent of function inputname() for output.
Best Answer