Menu

Post image 1
Post image 2
1 / 2
0

Generics in CrabPascal: TList and TDictionary (v2.15.0) | Generics no CrabPascal: TList e TDictionary (v2.15.0)

DEV Community·CrabPascal·3 months ago
#iQwCnUG5
Reading 0:00
15s threshold

Bilingual post · Post bilíngue Jump to: English · Português English {#english} Generics in CrabPascal: TList and TDictionary (v2.15.0) Generic collections are the backbone of modern Delphi — caches, registries, JSON maps. Sprint 7 ( v2.15.0 ) shipped System.Generics.Collections with working TDictionary<K,V> and TList<T> , including the all-important TryGetValue with var parameters. Dictionary basics program DictDemo ; uses System . SysUtils , System . Generics . Collections ; var D : TDictionary < string , Integer >; V : Integer ; begin D := TDictionary < string , Integer >. Create ; try D . Add ( 'apples' , 3 ); D . Add ( 'oranges' , 5 ); if D . TryGetValue ( 'apples' , V ) then WriteLn ( 'apples = ' , V ) else WriteLn ( 'not found' ); finally D . Free ; end ; end . Enter fullscreen mode Exit fullscreen mode TryGetValue writes into V only when the key exists — the Delphi pattern you expect in production code.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More