<p>Am 28.02.2017 09:37 schrieb "Andreas Frieß via Lazarus" <<a href="mailto:lazarus@lists.lazarus-ide.org">lazarus@lists.lazarus-ide.org</a>>:<br>
><br>
> I have found some interesting working Generics construct. I want to translate this code to Lazarus, but there are Generics often used.<br>
> In Delphi Berlin the following ist working, the inner array of Integer is normally 6 integer long, but once 7 integer and can filled in such way. Is it possible to do something similar in Lazarus ? Or how can i rewrite this to to the same in Lazarus/FPC</p>
<p>That has nothing to do with generics, but with array initializers, which FPC currently doesn't support.<br>
You can work around this by explicitly declaring the types and then using .Create().</p>
<p>=== code begin ===</p>
<p>type<br>
TInnerArray = TArray<Integer>;<br>
TOuterArray = TArray<TInnerArray>;</p>
<p>var<br>
CODE_PATTERNS: TOuterArray;</p>
<p>begin<br>
CODE_PATTERN := TOuterArray.Create(<br>
TInnerArray.Create(2, 1, 2, 2, 2, 2),<br>
TInnerArray.Create(2, 2, 2, 1, 2, 2), TInnerArray.Create(2, 2, 2, 2, 2, 1), TInnerArray.Create(1, 2, 1, 2, 2, 3), ...<br>
);<br>
end.</p>
<p>=== code end ===</p>
<p>While this looks quite verbose it should also work with Delphi. (In theory TArray<Integer>.Create() and TArray<TArray<Integer>>.Create() directly should work as well, but I think FPC's parser still barfs on that)</p>
<p>Regards,<br>
Sven</p>