I have noticed some unexpected behaviour with method chaining. Specifically I have a class A from which I want to call the static method to create class B:
classdef A methods (Static) function b = getB(args) b = B(args); end endend
And then I want to use class B to do something e.g. use the print() method, where class B is:
classdef B properties Property1 end methods function self = B(args) self.Property1 = args; end function print(self) fprintf(self.Property1); end endend
Trying
A.getB(args).Property1
succeeds.
I would thus also expect
A.getB(args).print()
to succeed, however, it gives the error:
Not enough input arguments.Error in A.getB (line 5) b = B(args);
Would anyone have any suggestions on why this is so? Thanks very much in advance.
Best Answer