Array of Record Type Initialization



Array of Record Type Initialization
Smart pascal source code
type TRec = record Field: Integer end; type TRec2 = record A : Integer; B : String; c : Boolean; end; { unit1.pas } const a1: array [0..0] of TRec = [(Field: 1)]; var a2: array [1..2] of TRec = [(Field: 2), (Field: 3)]; a3: array [0..1] of TRec2 = [ (A: 1; b: "One"; c: True),(A: 2; B: 'two'; c: False)]; begin Writeln(a1[0].Field); // 1 Writeln(a2[1].Field); // 2 Writeln(a2[2].Field); // 3 { test II } for var i in a3 do begin WriteLn(i.A); // 1 2 WriteLn(i.B); // one two WriteLn(i.C); // true false end;