Ada Programming/Attributes/'Succ

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

Ada Lovelace 1838.jpg

Contents


[edit] Description

X'Succ(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 greater than the input parameter.

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

[edit] Example

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

[edit] See also

[edit] Wikibook

[edit] Ada Reference Manual

Personal tools
Namespaces
Variants
Actions
Navigation
Community
Toolbox
Sister projects
Print/export