Enum Const



Enum Const
Smart pascal source code
type TTestEnum = (teOne, teTwo, teThree, teFour); function Reverse1(const value: TTestEnum): TTestEnum; const cTestEnumReversed: array [0 .. 3] of TTestEnum = (teFour, teThree, teTwo, teOne); begin Result := cTestEnumReversed[Ord(value)]; end; function Reverse2(const value: TTestEnum): TTestEnum; const cTestEnumReversed: array [TTestEnum] of TTestEnum = (teFour, teThree, teTwo, teOne); begin Result := cTestEnumReversed[value]; end; WriteLn(Reverse1(teOne) = teFour); WriteLn(Reverse2(teOne) = teFour); { <<< CONSOLE OUTPUTS >>> True True }