3 ms·
To be fair, getValueOrDefault is strictly more powerful than defaultdict because you can vary the initial value by the key.
by kbsletten 8y ago
To be fair, getValueOrDefault is strictly more powerful than defaultdict because you can vary the initial value by the key.
- detaro 8y agodict.get() does the same in Python (optional second parameter for a default value). But I've wondered too why there isn't a form of the default dict that can take parameters like the key for the factory function.