question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implicit default value for optional key in mappings?

See original GitHub issue

According 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-keys 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:closed
  • Created 5 years ago
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
crdoconnorcommented, Oct 29, 2018

Implemented in version 0.15.0. Let me know if you see any issues.

1reaction
crdoconnorcommented, Nov 3, 2018

Sorry that took so long. It’s fixed now in 0.15.1 and your tests now seem to be passing.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found