Skip to content

Commit 5c36d03

Browse files
committed
simplify 'Valid example
1 parent 9389565 commit 5c36d03

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

courses/fundamentals_of_ada/030_basic_types/11-subtypes_full_picture.rst

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -191,26 +191,24 @@ Valid attribute
191191
.. code:: Ada
192192
193193
procedure Main is
194-
type Small_Odd is new Integer range 0 .. 5
195-
with Predicate => Small_Odd mod 2 = 1;
196-
O : aliased Small_Odd;
197-
O_Alias : aliased Integer with Address => O'Address;
194+
subtype Small_T is Integer range 1 .. 3;
195+
Big : aliased Integer := 0;
196+
Small : Small_T with Address => Big'Address;
198197
begin
199-
for I in 0 .. 10 loop
200-
O_Alias := I;
201-
Ada.Text_IO.Put_Line (Boolean'Image (O'Valid));
198+
for V in 0 .. 5 loop
199+
Big := V;
200+
Put_Line (Big'Image & " => " & Boolean'Image (Small'Valid));
202201
end loop;
203202
end Main;
204203
205204
.. code::
206205
207-
FALSE
208-
TRUE
209-
FALSE
210-
TRUE
211-
FALSE
212-
TRUE
213-
FALSE
206+
0 => FALSE
207+
1 => TRUE
208+
2 => TRUE
209+
3 => TRUE
210+
4 => FALSE
211+
5 => FALSE
214212
215213
------------------------
216214
Idiom: Extended Ranges

0 commit comments

Comments
 (0)