Jump to content

Ada Programming/Attributes/'First

From Wikibooks, open books for an open world

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

Description

[edit | edit source]

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

[edit | edit source]
type My_Enum is (Enum1, Enum2, Enum3); type My_Int isrange -1 .. 5; ... pragmaAssert (My_Enum'First = Enum1); -- OKpragmaAssert (My_Int'First = -1); -- OKpragmaAssert (My_Int'First = 0); -- Wrong!

See also

[edit | edit source]

Wikibook

[edit | edit source]

Ada Reference Manual

[edit | edit source]
close