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

조회 수: 1 (최근 30일)
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?

답변 (0개)

카테고리

Help CenterFile Exchange에서 Entering Commands에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by