with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Text_IO; use Ada.Text_IO; procedure tryArrays4 is -- s: string(1..10) := "abcdefghij"; s: string := "abcdefghij"; m, n: Integer; Type MyArray is array (1 .. 10) of Integer; a: MyArray := (11, 12, 13, 14, 15, 16, 17, 18, 19, 20); b: MyArray := (81, 82, 83, 84, 85, 86, 87, 88, 89, 90); begin -- String slice: We've seen this put_line( s(2 .. 5) ); -- Slice bounds can be dynamic m := 3; n := 5; put_line( s(m .. n) ); -- Assign a slice with an aggregate value a(2 .. 4) := (-1, -2, -3); -- Warning of runtime error if aggregate is wrong size -- Now let's see what is in a for i in a'range loop put(a(i), width=>4); end loop; new_line; -- Assign one slice to another a(1 .. 3) := a(8 .. 10); for i in 1..10 loop -- Let's look a the slice put(a(i), width=>4); end loop; new_line; -- When slices overlap, the values shift a(1 .. 9) := a(2 .. 10); for i in a'range loop -- Look at the slice put(a(i), width=>4); end loop; new_line; -- Types on both sides of assignment must be identical -- a(1 .. 3) := b; -- Will compile but warns of runtime error a(1 .. 3) := b(1..3); -- Okay end tryArrays4;