1

I have M : array (1..3, 1.. 3) of Integer := ((0, 0, 0), (0, 0, 0), (0, 0, 0));

I am looking to convert the size of this to be user-determined, i.e., the new array would look something like M : array (1 .. user_size, 1 .. user_size) of ...

The problem I'm having is the case of zero-ing out the array. I'm not extremely familiar with Ada, but learning.

Is there a way to do this?

Jud
  • 1,324
  • 3
  • 24
  • 47

1 Answers1

8

try

(others => (others => 0));
egilhh
  • 6,464
  • 1
  • 18
  • 19
  • Wow. This is way easier than anything I have tried. Thanks for introducing me to aggregates. I just went and looked it up in the documentation. Will accept answer once SO allows me to. – Jud Sep 16 '16 at 14:41
  • 5
    Note you can allocate named elements first then the "others" clause, e.g. (1 => 99, 2 => 101, others => 0) will set the first two elements to a different value. –  Sep 16 '16 at 14:44