Search code examples
javaadaanonymous-typesanonymousada2012

Unnamed records in Ada


In Java, you would be able to do something like this:

ArrayList.add(new Object(int arg1, int arg2);

creating an object without a name and adding it to a list, making it easy to use in a loop.

How would I do similar in Ada using records?

I have a record:

    type Food is
       record
            Name: Character;
            Taste: Integer;
       end record;

How would I create instances of the record and add it to an array without naming them?


Solution

  • Sound a bit too much like homework to give a direct answer, but you can read about Record Aggregates here: RM 4.3.1