Classdef: Difference between revisions

From Octave
Jump to navigation Jump to search
(array of classdef objects)
(immutable property set access not supported in 4.0.0)
Line 21: Line 21:
cc = {c, c};  % ok
cc = {c, c};  % ok
</source>
</source>
* [http://www.mathworks.com/help/releases/R2015a/matlab/matlab_oop/mutable-and-immutable-properties.html Immutable property] set access. Example:
<source lang="octave">
classdef MyClass < handle
    properties (SetAccess = immutable)
        x
    end
    methods
        function obj = MyClass()
            x = rand();
        end
    end
end
</source>
Use "private" properties as workaround.


==== supported ====
==== supported ====

Revision as of 09:20, 15 June 2015

This page is a stub. We should begin documenting what classdef is implemented and what is not.

not supported

  • enumeration
  • build-in class as superclass
    • classdef nonsense < uint32
  • array of objects. Example:
classdef MyClass < handle
end

c = MyClass();
cc = [c, c];   % won't work

For now you can use a cell-array of objects instead:

cc = {c, c};   % ok
classdef MyClass < handle
    properties (SetAccess = immutable)
        x
    end
    methods
        function obj = MyClass()
            x = rand();
        end
    end
end

Use "private" properties as workaround.

supported

  • methods
    • static
    • private

Classdef examples in the wild