Using dynamic references to dynamic properties within those property's common set/get method.
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a class which is a subclass of dynamicprops.
I specify a common get method for each dynamic property by using an anonymous function that references a set method but also provides the name of the property. Similar to the following:
metaprop = obj.addprop(name); metaprop.GetMethod = @(obj) getProp(obj,name);
getProp is defined as the folowing method of the class:
function val = getProp(obj,propertyName) val = obj.(propertyName); end
This ends up throwing an error, "Maximum recursion limit of 501 reached." It seems that even though I am accessing that function from within the get property function, it is still calling the get method. Must be because the actual get method is the anonymous function so it doesn't recognize the getProp as the get method and so calls the anonymous function again for obj.(propertyName) Any better ideas to fix this?
Antworten (0)
Siehe auch
Kategorien
Mehr zu Handle Classes finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!