Anonymous Dynamic Record



Dynamic Anonymous Record
Pas2JS pascal source code
var i: Integer; Begin i := 123; function Get123: array [1 .. 3] of Integer; begin Result := [1, 2, 3]; end; var r := record fi := i; fi2 := i*2; fis := '<'+IntToStr(i)+'>'; f123 := Get123; property pi : Integer read fi; function pis : string; begin Result:='['+IntToStr(pi)+']'; end; end; WriteLn(r.fi); WriteLn(r.fi2); WriteLn(r.fis); WriteLn(r.pis); WriteLn(r.f123[1]); WriteLn(r.f123[2]); WriteLn(r.f123[3]); var r2 := r; r.fi := 456; WriteLn(r.pi); WriteLn(r2.pi); WriteLn(r2.fis); WriteLn(r.pis); WriteLn(r2.pis); WriteLn(r2.f123[1]); WriteLn(r2.f123[2]); WriteLn(r2.f123[3]); { <<< CONSOLE OUTPUTS >>> 123 246 <123> [123] 1 2 3 456 123 <123> [456] [123] 1 2 3 } end;