File tree Expand file tree Collapse file tree 1 file changed +12
-14
lines changed
courses/fundamentals_of_ada/030_basic_types Expand file tree Collapse file tree 1 file changed +12
-14
lines changed Original file line number Diff line number Diff 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------------------------
216214Idiom: Extended Ranges
You can’t perform that action at this time.
0 commit comments