Ada Programming/Attributes/'Image

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

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

Description[edit | edit source]

X'Image(Y) is an Ada attribute where X is any discrete type and Y is an instance of that type. This attribute returns a string representation of the value passed as input.

This attribute is a useful way to automatically convert from a type value to a string suitable for output.

Example[edit | edit source]

type My_Enum is (Enum1, Enum2, Enum3);
...
pragma Assert (My_Enum'Image (Enum1) = "ENUM1");

See also[edit | edit source]

Wikibook[edit | edit source]

Ada Reference Manual[edit | edit source]