Skip to content

defaultdict

defaultdict<K, V>(factory: () => V): Map<K, V> & object

Defined in: packages/pythonlib/src/collections.ts:109

defaultdict: a dict that provides default values for missing keys

Uses a Proxy to automatically call the factory function for missing keys.

Type Parameters

Type Parameter
K
V

Parameters

ParameterType
factory() => V

Returns

Map<K, V> & object