Quick demo of how to initialize your data structure with optional configuration parameters ... with sane defaults if left unspecified.
This functional config technique ...
- lets you write APIs that can evolve without pain
- provides meaningful configuration parameters
- makes it easy to set default settings
- makes it possible to set complex conditional values
See the posts by Rob Pike ("Self-referential functions and the design of options") and Dave Cheney ("Functional options for friendly APIs") for more details on this technique.