使用包 Enumeration IO

我們只能使用泛型包 Ada.Text_IO.Enumeration_IO 來列印文字,而不是列舉文字中的屬性 ImageAda.Text_IO.Put

with Ada.Text_IO; use Ada.Text_IO;

procedure Main is
   type Fruit is (Banana, Pear, Orange, Melon);
   package Fruit_IO is new Enumeration_IO (Fruit); use Fruit_IO;
begin
   for I in Fruit loop
      Put (I);
      New_Line;
   end loop;
end;

結果

BANANA
PEAR
ORANGE
MELON