問題文
A module accepts an object with several attributes, and the author wants callers to be able to omit two of them and get sensible defaults. Which mechanism fits?
選択肢
- Declare a separate variable for each optional attribute with its own default, and assemble the object inside the module.
- Mark those attributes as optional in the object type constraint and give each one a default value there.
- Use a map type instead of an object type, and merge the caller's map with a map of defaults inside the module, since object types require every attribute to be present and cannot express optionality.
- Give the whole variable a default value that contains the two attributes, so callers who omit them get those values.