Name
Succ Function
Syntax
function Succ(const Value): Ordinal type
;
Description
The Succ
function returns the successor of an
ordinal value, usually an enumerated value. That is, it returns the
enumerated value whose ordinal value is one more than
Value
. Succ
is not a
real function.
Tips and Tricks
Inc
,Succ
, and addition by one have similar performance, so choose the one that you find most clear and easy to read.Calling
Succ(High(
SomeType
))
raises runtime error 4 (ERangeError
). Without overflow checking, though,Succ
returns a value with the desired ordinal value, even though that value is not valid for the type.
Example
type TDay =
(Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday);
var
Day: TDay;
begin
Day := Succ(Day);
...
See Also
Dec Procedure, High Function, Inc Procedure, Low Function, Pred Function, $OverflowChecks Compiler Directive, $Q Compiler Directive |
Get Delphi in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.