swap record



swap_record
Smart pascal source code
type TRec1 = record a: Integer; end; var r1: TRec1 = (a: 1); var r2: TRec1 = (a: 2); WriteLn(r1.a); WriteLn(r2.a); Swap(r1, r2); WriteLn(r1.a); WriteLn(r2.a); type TRec2 = record a, b: Integer; end; var z1: TRec2 = (a: 10; b: 2); var z2: TRec2 = (a: 30; b: 4); WriteLn(z1.a + z1.b); WriteLn(z2.a + z2.b); Swap(z1, z2); WriteLn(z1.a + z1.b); WriteLn(z2.a + z2.b); {<<< RESULT - CONSOLE LOG >>> ----------------------------- 12 21 1234 3412 ----------------------------- {<<<<<<<<< THE END >>>>>>>>>}