Smart pascal source code
type
TMyObject = class
public
function getText: String; virtual;
end;
function TMyObject.getText: String;
begin
result := 'We can ';
end;
type
TSecond = class(TMyObject)
public
function getText: String; override;
End;
function TSecond.getText: String;
begin
result := inherited getText + 'do it!';
end;
var o := TSecond.Create;
WriteLn(o.getText);
{<<< RESULT - CONSOLE LOG >>>
-----------------------------
Errors >>>>
Hint: "result" does not match case of declaration ("Result") [line: 9, column: 4]
Hint: "result" does not match case of declaration ("Result") [line: 20, column: 4]
Result >>>>
We can do it!
-----------------------------
{<<<<<<<<< THE END >>>>>>>>>}
var TMyObject = {
$ClassName:"TMyObject",$Parent:TObject
,$Init:function ($) {
TObject.$Init($);
}
,getText:function(Self) {
return "We can ";
}
,Destroy:TObject.Destroy
,getText$:function($){return $.ClassType.getText($)}
};
var TSecond = {
$ClassName:"TSecond",$Parent:TMyObject
,$Init:function ($) {
TMyObject.$Init($);
}
,getText:function(Self) {
return TMyObject.getText(Self)+"do it!";
}
,Destroy:TObject.Destroy
,getText$:function($){return $.ClassType.getText($)}
};
var o = null;
/* <<< main JS >>> */
o = TObject.Create($New(TSecond));
WriteLn(TMyObject.getText$($Check(o,"")));