Is there more direct evidence indicating that the values of enumeration members are referenced by the constructor of the enumeration class?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
In the book I've read, it was mentioned that the values of enumeration members are passed as parameters to the constructor of the enumeration class. I was hoping to find more information about this in the MATLAB documentation, but I could only find some indirect evidence, , like this page. (Define Properties in Enumeration Classes)
classdef SyntaxColors
properties
R
G
B
end
methods
function c = SyntaxColors(r, g, b)
c.R = r; c.G = g; c.B = b;
end
end
enumeration
Error (1, 0, 0)
Comment (0, 1, 0)
Keyword (0, 0, 1)
String (1, 0, 1)
end
end
run:
e = SyntaxColors.Error;
e.R
ans =
1
However, I couldn't find more in-depth explanations.
For example, can the values of enumeration members be characters or strings?
classdef Bearing
enumeration
North ("N")
East ("E")
South ("S")
West ("W")
end
end
Can they be cell?
classdef Bearing
enumeration
North {0}
East {90}
South {180}
West {270}
end
end
Can they be objects of other classes?
I couldn't find any relevant information in my search of the official documentation. Is there official MATLAB documentation on this topic?
0 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Construct and Work with Object Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!