First time trying generics, but I fail. I try to write a generic method that could process different types of maps (int16, int32, double etc). So I tried something like this:
interface
type
TInt16Map = Array of Array of int16;
TInt32Map = Array of Array of int32;
implementation
generic procedure Dummy<T>(x,y:integer; map:T);
begin
map[x,y]:=1;
end;
but the compiler doesn't like map[x,
y]. (Illegal qualifier)
So, I guess I would have to restrict the possible types to the actual 2d arrays?
generic procedure Dummy<T: TInt16Map, TInt32Map>(x,y:integer; map:T);
begin
map[x,y]:=1;
end;
But that fails with Error: Class or interface type expected, but got "TInt16Map".
Am I right though in assuming that a global method (not a class method) can be generic? I mostly read of generics in the context of classes