Class Self reference |
Smart pascal source code
type TMyObj = class function GetSelf: TMyObj; end; function TMyObj.GetSelf: TMyObj; begin Result := Self; end; { main.pas } var o = TMyObj.Create; Begin if o <> o.GetSelf then Writeln('bug'); WriteLn(o.GetSelf); { ### CONSOLE OUTPUTS ### {"ClassType":{"$ClassName":"TMyObj","$Parent":{"$ClassName":"TObject","$Parent":null}}} }