fpc 3.2.2可以使用delphi的泛型,需要在单元添加:
{$mode delphi}
,并在uses 加上Generics.Collections后才能编译
program project1; //{$mode objfpc}{$H+} {$mode delphi}{$H+} uses Generics.Collections; var d:TDictionary<byte,byte>; i:byte; begin d:=TDictionary<byte,byte>.create; d.tryadd(3,4); if d.trygetvalue(3,i) then writeln(i); d.free; end.