Created
May 19, 2014 09:15
-
-
Save freeonterminate/0dea34094dc0066363bb to your computer and use it in GitHub Desktop.
Delphi Generics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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