File
174528164685.png
- (600B
, 32x32
, MAINICON.png
)
TL;DR: how do I passed nil to an overloaded method that expects a delegate type argument?
Consider:
unit Autism;
interface
uses SysUtils;
type
TMyDelegate = function(Over9000: Integer): Boolean of object;
TMyShittyClass = class
private
FChargingMahLazor: Boolean;
FCallBack: TMyDelegate;
public
constructor Create(LazorStatus: Boolean); overload;
constructor Create(LazorStatus: Boolean; ACallBack: TMyDelegate); overload;
end;
implementation
constructor TMyShittyClass.Create(LazorStatus: Boolean); overload;
begin
Create(LazorStatus, nil);
end;
constructor TMyShittyClass.Create(LazorStatus: Boolean; ACallBack: TMyDelegate); overload;
begin
FChargingMahLazor := LazorStatus;
FCallBack := ACallBack;
end;
end.
This gives you "there is no overloaded version that can be called with these arguments". Because it has to be typed, not just Pointer. But casting it to TMyDelegate does not work either (as in "TMyDelegate(nil)"). I have found a decent workaround and something that is probably going to summon Cthulhu eventually but I'd prefer a good solution.