使用包 Enumeration IO
我们只能使用泛型包 Ada.Text_IO.Enumeration_IO
来打印文字,而不是枚举文字中的属性 Image
和 Ada.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