2 ms·
What happens when your values are computed? Or expensive to compute, and your map starts to get big? E.g.: {'a': foo(), 'b': bar() }[...] If foo() or bar(
by dymk 8y ago
What happens when your values are computed? Or expensive to compute, and your map starts to get big? E.g.:
{'a': foo(), 'b': bar() }[...]
If foo() or bar() ever introduce side-effects or become expensive, you're gonna have a hell of a time figuring out what's going wrong.
- Riobe 8y agoIf your values are expensive to compute like that, then you'd have the object return a function that would call foo(), bar(), and so on; and you wouldn't call them all to setup the map in the first place.
- Izkata 8y agoThis is in fact demonstrated in the second example in "Working with functions"...