Enum | Succ | Pred



Enum | Succ | Pred example
Pas2JS pascal source code
type TEnum = (enOne, enTwo, enThree); var e: TEnum = enTwo; WriteLn('Ord: ' + IntToStr(Ord(e))); WriteLn('High: ' + IntToStr(Ord(High(e)))); WriteLn('Low: ' + IntToStr(Ord(Low(e)))); Inc(e); // supported WriteLn(Ord(e)); Dec(e); // supported WriteLn(Ord(e)); WriteLn(Succ(e)); WriteLn(Pred(e)); for e := enOne to enThree do WriteLn(e); WriteLn(''); for e := Low(TEnum) to High(TEnum) do WriteLn(e); WriteLn(''); { <<< CONSOLE OUTPUTS >>> Ord: 1 High: 2 Low: 0 2 1 2 0 012 012 }