Implicit default value for optional key in mappings?
See original GitHub issueAccording to the optional keys docs and the sources there is no support for an implicit default value for an optional key. My use case: I potentially have to configure a very long list of key value mappings for my command line application. The majority of the optional-key
s usually have a default value which is implicit but from application/user perspective reasonable, not surprising. I know implicit data may be bad. Anyway… what do you think?
- mandatory-key: ...
optional-key:
- mandatory-key: ...
optional-key:
(... potentially very long list of other mappings ...)
Issue Analytics
- State:
- Created 5 years ago
- Comments:16 (9 by maintainers)
Top Results From Across the Web
Optional keys with defaults (Map/Optional) - HitchDev
When parsed the result will include the optional value: ... schema = Map({"a": Int(), Optional("b", default=None, drop_if_none=False): EmptyNone() | Bool(), }) ...
Read more >How to give default value for a optional with generic type in ...
I was trying to simpify my question but apprently it ended up rather confusing. As I understand, both Map have the same Key...
Read more >Adding `defaultValue` method to Optional - Swift Forums
In the future we might be able to use this with key-path method literals. arrayWithOptionalStrings.map(\.defaultValue("default")).
Read more >default values for maps - Google Groups
A map lookup also returns an optional boolean value [1], which indicates whether the lookup was successful or not -- without blowing
Read more >Optional object type attributes with defaults in v1.3 alpha ...
For completeness and for anyone else who is reading who might have a different situation: note that {} was only a valid default...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Implemented in version 0.15.0. Let me know if you see any issues.
Sorry that took so long. It’s fixed now in 0.15.1 and your tests now seem to be passing.