I don't see such special use cases as good candidates to be included in 
builtins libraries.

Em segunda-feira, 18 de dezembro de 2023 às 07:56:11 UTC-3, DaTrader 
escreveu:

> Many times I need to merge a subset of a keyword list or a map into 
> another keyword list or map while requiring it to fail if not all keys are 
> present.
>
> For this purpose I have small utility modules called KwUtils and MapUtils 
> where I have functions like the one below:
>
> ```
>   @doc """
>   Takes specified key-value pairs from the keyword list but raises if any 
> not found.
>   """
>   @spec take!( keyword(), [ atom()]) :: keyword()
>   def take!( kw, keys) do
>     taken = Keyword.take( kw, keys)
>
>     if length( taken) != length( keys) do
>       raise "Expected all keys in #{ inspect( keys)} to be present in #{ 
> inspect( kw)}"
>     end
>
>     taken
>   end
> ```
>
> It'd be nice if a corresponding function was part of the `Keyword` and 
> `Map` modules each.
>
>

-- 
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 elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/be1e0fa2-4872-48a9-b106-d3128d18bff4n%40googlegroups.com.

Reply via email to