Error while redefining subsref for object, if there are methods with no output arguments

조회 수: 1 (최근 30일)
I am trying to redefine brackets operator for my class, as written here: Code Patterns for subsref and subsasgn Methods
So, for all other subscripts except of '()' I should call buil-it function:
varargout = subsref(obj,s)
if ~strcmp(S(1).type, '()')
varargout = {builtin('subsref',obj,S)};
else
... % do something else
end
end
But when I call some methods with dot subscript, which do not return any arguments,
myObject.push_back(3);
My builtin function returns no value for varargout and throws an error: "Too many output arguments."
Next, I have found that I should redefine numArgumentsFromSubscript method. But the problem is, when I call a method that have no return arguments, it does not call numArgumentsFromSubscript.
  댓글 수: 1
Victor
Victor 2017년 4월 10일
편집: Victor 2017년 4월 10일
UPD: Already solved it by adding 'obj' output to every methods, even to subasgn:
function obj = subsasgn(obj,S,inData)
instead of
function subsasgn(obj,S,inData)
and so on.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by