Consider:
TTest <T : class, constructor> = class
public
function CreateMyObject : T;
end;
function TTest<T>.CreateMyObject : T;
var
Obj : TObject;
begin
Obj := T.Create;
Result := (Obj as T);
end;
Why isn't this possible? Compiler yields an "Operator not applicable to this type" error message for the as operator. T is constrained to be a class type, so this should work, shouldn't it?
Thanks for the help.