Ada Programming/Attributes/'Pred

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Ada. Time-tested, safe and secure.
Ada. Time-tested, safe and secure.

Description[edit | edit source]

X'Pred(Y) is an Ada attribute where X is any discrete type and Y is a value of that type. This attribute represents the discrete value that has a position number of one less than the input parameter.

The returned discrete value type is the base type of discrete type. If the input parameter is the First value of the discrete type, then a CONSTRAINT_ERROR exception will be raised.

Example[edit | edit source]

type My_Enum is (Enum1, Enum2, Enum3);
...
pragma Assert (My_Enum'Pred (Enum2) = Enum1); -- OK
pragma Assert (My_Enum'Pred (Enum1) = Enum3); -- OK

See also[edit | edit source]

Wikibook[edit | edit source]

Ada Reference Manual[edit | edit source]