0

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?

Amandeep
  • 11
  • 3
  • 1
    Note that all objects are references in Java. In Ada, though, you can choose whether your list will have actual records, or accesses to records. The answer will depend on which one you want. Note also that you managed to pack four errors in that one line of Java code. – ajb Mar 06 '15 at 07:06

1 Answers1

2

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

egilhh
  • 6,464
  • 1
  • 18
  • 19