Is there more direct evidence indicating that the values of enumeration members are referenced by the constructor of the enumeration class?
조회 수: 4 (최근 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에서 Construct and Work with Object Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!