diff --git a/objects.m b/objects.m index ffee69c..c0df3c2 100644 --- a/objects.m +++ b/objects.m @@ -1,3 +1,5 @@ +clear; + % instantiate an object of type BasicClass (see BasicClass.m) obj = BasicClass; @@ -15,6 +17,12 @@ obj.roundOff(); v = BasicClass(42); assert(v.Value == 42); +% all properties can be enumerated +assert(isequal(properties(v), {'Value'}')); + +% and all methods +assert(isequal(methods(v), {'BasicClass', 'multiplyBy', 'plus', 'roundOff'}')); + % object arrays are presto supported objs(1) = BasicClass(44); objs(2) = BasicClass(33); @@ -26,7 +34,7 @@ assert(isequal( [objs.Value], [44 33] )); assert(isequal( {objs.Value}, {44, 33} )); % operator overloading -obj + objs(1); +v + v; % also works for object arrays -[objs] + [objs] \ No newline at end of file +[objs] + [objs]; \ No newline at end of file