Azzera filtri
Azzera filtri

Using dynamic references to dynamic properties within those property's common set/get method.

2 visualizzazioni (ultimi 30 giorni)
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?

Risposte (0)

Categorie

Scopri di più su Entering Commands in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by