Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pascal - hard-coding data in array - shortcut

Here's what I'm trying to do:

T[1]:=5;
T[2]:=3;
.
.
.
T[9]:=20;

Is there a shortcut to achieving this where I can assign the values in a single line?

like image 746
itsols Avatar asked Dec 30 '25 12:12

itsols


1 Answers

I could not find this in any of the documentations but I tried this and it works!

Here's the method used with a complete example:

Program StrangeArray;

Var T: Array[1..5] of Integer = (554,434,144,343,525);
    x:integer;

Begin
For x:=1 to 5 Do
    Begin
    Writeln(T[x]);

    End;

End.

Hope this is useful for others as well.

like image 113
itsols Avatar answered Jan 03 '26 02:01

itsols