Skip to content

Instantly share code, notes, and snippets.

@freeonterminate
Created May 19, 2014 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save freeonterminate/0dea34094dc0066363bb to your computer and use it in GitHub Desktop.
Save freeonterminate/0dea34094dc0066363bb to your computer and use it in GitHub Desktop.
Delphi Generics
program Project1;
uses
System.SysUtils;
type
TTest<T> = record
Value: 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;
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