< Ada Programming < Attributes
![](../../../I/m/Ada_Mascot_with_slogan.svg.png)
Ada. Time-tested, safe and secure.
Description
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
type
My_Enumis
(Enum1, Enum2, Enum3); ...pragma
Assert (My_Enum'Pred (Enum2) = Enum1); -- OKpragma
Assert (My_Enum'Pred (Enum1) = Enum3); -- Wrong
See also
Wikibook
Ada Reference Manual
This article is issued from
Wikibooks.
The text is licensed under Creative
Commons - Attribution - Sharealike.
Additional terms may apply for the media files.