使用屬性 Image 列印列舉
with Ada.Text_IO;
procedure Main is
type Fruit is (Banana, Orange, Pear);
X : Fruit := Orange;
begin
Ada.Text_IO.Put_Line (Fruit'Image (X));
end Main;
結果
ORANGE
with Ada.Text_IO;
procedure Main is
type Fruit is (Banana, Orange, Pear);
X : Fruit := Orange;
begin
Ada.Text_IO.Put_Line (Fruit'Image (X));
end Main;
ORANGE