Function Pointer field no param



Function Pointer field no param
Smart pascal source code
type TOnGetValue = function: string of object; type TTestClass = class private fOnGetValue: TOnGetValue; public function Get: string; property OnGetValue: TOnGetValue read fOnGetValue write fOnGetValue; end; function TTestClass.Get: string; begin if Assigned(fOnGetValue) then Result := fOnGetValue // LINE WITH COMPILE ERROR! else Result := 'event not assigned'; end; type TMainClass = class function DoIt: string; function GetValue: string; end; function TMainClass.GetValue: string; begin Result := 'passed'; end; function TMainClass.DoIt: string; begin var Test: TTestClass = TTestClass.Create; try Test.OnGetValue := GetValue; Result := Test.Get; finally Test.free end; end; begin var M: TMainClass = TMainClass.Create; WriteLn(M.DoIt); end; {<<< RESULT - CONSOLE LOG >>> ----------------------------- Errors >>>> Hint: OF OBJECT modifier is legacy and ignored [line: 2, column: 37] Hint: "result" does not match case of declaration ("Result") [line: 28, column: 2] Hint: "result" does not match case of declaration ("Result") [line: 36, column: 2] Hint: "free" does not match case of declaration ("Free") [line: 38, column: 7] Result >>>> passed ----------------------------- {<<<<<<<<< THE END >>>>>>>>>}