record method



record_method
Smart pascal source code
type TTest = record private FHidden: String; public Field: Integer; private procedure SetHidden(v: String); begin FHidden := v; end; function GetIdx(i: Integer): String; public property Shown: String read FHidden write SetHidden; property Idx[i: Integer]: String read GetIdx; default; procedure SayHello; class function NewOne(s: String): TTest; begin Result.FHidden := s; Result.Field := 123; end; end; function TTest.GetIdx(i: Integer): String; begin Result := Shown + IntToStr(i); end; procedure TTest.SayHello; begin WriteLn('Hello ' + FHidden); end; var t: TTest; t.Shown := 'World'; t.SayHello; WriteLn(t.Idx[123]); WriteLn(t[456]); t := TTest.NewOne('New one'); t.SayHello; WriteLn(t.Field); {<<< RESULT - CONSOLE LOG >>> ----------------------------- Hello World World123 World456 Hello New one 123 ----------------------------- {<<<<<<<<< THE END >>>>>>>>>}