Clear the class to reload the definition of the HandleColors class:
clear classes
a = HandleColors.Red;
a.R
ans =
1
To prevent reassignment of a given property value, set that property's SetAccess
attribute to immutable.
Equality of Handle-Based Enumerations
Assign two variables to a particular enumeration member:
a = HandleColors.Red;
b = HandleColors.Red;
Compare a and b using isequal:
isequal(a,b)
ans =
1
The property values of a and b are the same, so isequal returns true. However, unlike
handle classes that are not enumeration classes, a and b are the same handle because
there is only one enumeration member. Determine handle equality using == (the handle
eq method).
a == b
ans =
1
See the handle eq method for information on how isequal and == differ when used
with handles.
14 Enumerations