Ada Programming/Attributes/'Last


Ada Lovelace 1838.jpg

DescriptionEdit

X'Last, where X is any scalar type (for example integer, enumerated, real), is an attribute that represents the last value (upper bound) in the range of type X. The value returned is of type X.

ExampleEdit

type My_Enum is (Enum1, Enum2, Enum3);
type My_Int  is range -1 .. 5;
... 
pragma Assert (My_Enum'Last = Enum3);  -- OK
pragma Assert (My_Int'Last  = 5);      -- OK
pragma Assert (My_Int'Last  = 4);      -- Wrong!

See alsoEdit

WikibookEdit

Ada Reference ManualEdit

Last modified on 5 January 2009, at 23:55