summaryrefslogtreecommitdiff
path: root/test.adb
diff options
context:
space:
mode:
authorrexim <reximkut@gmail.com>2024-03-13 23:22:18 +0700
committerrexim <reximkut@gmail.com>2024-03-13 23:22:18 +0700
commit0d6bc4cdc89c98cd37994e9539200d7c009907e5 (patch)
tree93d9ac3ffe8f282180c13f13d85d0dd752b0123f /test.adb
parent29cb48cedb43034355e602d57b73b22fb785f5ca (diff)
Finally! Useful Unions!
Diffstat (limited to 'test.adb')
-rw-r--r--test.adb25
1 files changed, 15 insertions, 10 deletions
diff --git a/test.adb b/test.adb
index 3c1ce14..a12a0af 100644
--- a/test.adb
+++ b/test.adb
@@ -4,15 +4,20 @@ with Ada.Strings; use Ada.Strings;
with Ada.Containers.Vectors;
procedure Test is
- package Queue is new
- Ada.Containers.Vectors(Index_Type => Natural, Element_Type => Integer);
- Q: Queue.Vector;
+ type Item_Kind is (Key, Bomb, Checkpoint);
+ type Item(Kind: Item_Kind := Key) is record
+ case Kind is
+ when Key | Checkpoint => null;
+ when Bomb =>
+ Cooldown: Integer;
+ end case;
+ end record;
+ type Map is array (Natural range <>) of Item;
+ type Map_Access is access Map;
+
+ Items: Map_Access := null;
begin
- for Index in 1..10 loop
- Q.Append(Index);
- end loop;
- while not Q.Is_Empty loop
- Put_Line(Integer'Image(Q(0)));
- Q.Delete_First;
- end loop;
+ Items := new Map(1..10);
+ Items(1) := (Kind => Bomb, Cooldown => 10);
+ Put_Line(Items.all'Image);
end;