I often want to extract a mandatory value from an options keyword list, and
continue treating the rest as less strict configuration.
This is a two-liner: mandatory = Keyword.fetch!(options, :mandatory);
optional = Keyword.delete(options, :mandatory)
I do this just often enough, I'd like to propose {mandatory, optional} =
Keyword.pop!(options, :mandatory)
- It fits in well with the current Map API
- It's simple to implement and maintain
- It provides an analog for the keyword variant of the (non-existent)
positional def foo(mandatory, *optional)
However it merely replaces a trivial two-liner, so this comes down to
others in core finding the idiom common enough to merit widening the Map
API surface area. I do, hence the proposal, but I'd love to hear
other's experiences.
--
You received this message because you are subscribed to the Google Groups
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elixir-lang-core/9da94be1-3419-4713-b9a8-4ac39b24cbc6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.