Ada Programming/Attributes/'First
< Ada Programming < AttributesComputing » Computer Science » Computer Programming » Ada Programming

Description
X'First
, where X
is any scalar subtype (for example integer, enumerated, real), is an attribute that represents the first value (lower bound) in the range of X
.
A'First
, where A
is an array, denotes the first index value. For more-dimensional arrays, A'First(N)
denotes the first index value of the Nth dimension (N must be static).
Example
type My_Enum is (Enum1, Enum2, Enum3); type My_Int is range -1 .. 5; ... pragma Assert (My_Enum'First = Enum1); -- OK pragma Assert (My_Int'First = -1); -- OK pragma Assert (My_Int'First = 0); -- Wrong!
See also
Wikibook
Ada Reference Manual
- 13.3 Operational and Representation Attributes (Annotated)
- Annex K Language-Defined Attributes (Annotated)
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.