Quote from: rnfpc on June 23, 2019, 03:00:27 pmIs there any way to have generic function here that will print any type of printable item array sent to it? Is it possible to have simple generic functions?In FPC 3.0 only via generic types:Code: Pascal [Select][+][-]{$APPTYPE CONSOLE}{$MODE DELPHI}type TPrintArray<T> = class(TObject) public class procedure DoPrint(const A: array of T); static; end; class procedure TPrintArray<T>.DoPrint(const A: array of T);var Item: T;begin for Item in A do Write(Item, ','); Writeln;end; begin TPrintArray<Integer>.DoPrint([1, 2, 3]); TPrintArray<string>.DoPrint(['11', '22', '33']); Readln;end.
Is there any way to have generic function here that will print any type of printable item array sent to it? Is it possible to have simple generic functions?