[Lazarus] Error: Generics without specialization cannot be used as a type for a variable

Sven Barth pascaldragon at googlemail.com
Wed May 11 14:23:04 CEST 2011


Am 10.05.2011 23:19, schrieb Hans-Peter Diettrich:
> Take e.g. a TObjectList, and replace all occurences of "TObject" by
> "<T>", to make it a generic class:
>
> TMyList<T> = class(TList)
> ...
> function Add(AObject: <T>): Integer;
> ...
> end;
>

You need to use "T", not "<T>". The "<T>" after the class name is 
basically a type declaration. You can use multiple types, too:

TMyDictionary<TKey, TValue> = class
   ...
   function Find(aKey: TKey): TValue;
   ...
end;

Regards,
Sven




More information about the Lazarus mailing list