Is there more direct evidence indicating that the values of enumeration members are referenced by the constructor of the enumeration class?
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Enumerations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!