Skip to content

Instantly share code, notes, and snippets.

@ritalin
Created May 19, 2014 09:50
Show Gist options
  • Save ritalin/91228af470e948ffd02c to your computer and use it in GitHub Desktop.
Save ritalin/91228af470e948ffd02c to your computer and use it in GitHub Desktop.
program RecGenerics;
uses
System.SysUtils;
type
IHogeClass<T> = interface;
TTest<T> = record
Value: T;
function Hoge: IHogeClass<TArray<T>>;
end;
IHogeClass<T> = interface
function Test: TTest<T>;
end;
THogeClass<T> = class(TInterfacedObject, IHogeClass<T>)
function Test: TTest<T>;
end;
function Test1: TTest<Integer>;
begin
Result.Value := 1;
end;
function Test2: TTest<TArray<Integer>>;
begin
SetLength(Result.Value, 1);
Result.Value[0] := 2;
end;
{ THogeClass<T> }
function THogeClass<T>.Test: TTest<TArray<T>>;
begin
end;
{ TTest<T> }
function TTest<T>.Hoge: IHogeClass<TArray<T>>;
begin
end;
begin
Writeln('test1 = ', Test1.Value);
Writeln('test2 = ', Test2.Value[0]);
Readln;
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment