> Maybe if you want to keep the other keys as is, then "rename_key" can be
handy
This is the use case I had in mind. Let's say I have a map with 100 keys,
but only need to rename one of them. In that event, today I would write
something like this:
{val, new_map} = Map.pop(original_map, :origin
This is a generalization of the existing (and oddly specific)
String.chunk/2 function that takes a string and a single-argument predicate
function, returning a list of strings.
e.g.
String.chunk_by(" foo bar ", &(&1 =~ ~r/\w/))
# => [" ", "foo", " ", "bar", " "]
The above example makes pro
ving whitespace*" cannot be easily solved this way.
On Wednesday, December 2, 2020 at 1:52:12 PM UTC-5 shanes...@gmail.com
wrote:
> Are there use-cases that you see for this feature that don't fall under
> String.split/3 with a regex argument?
>
> https://hexdocs.pm/elixir/String.ht
A common task is to iterate over a map performing some operation thereby
producing a new map. There are some ways to do this in Elixir presently,
the simplest probably being for...into:
for {key, val} <- map, into: %{} do
{key, val * 2}
end
Enum.reduce/3 is also an option. However, Erlang pro
>
> That said, `maps:map/2` is available:
>
> `:maps.map(fn _k, v -> v * 2 end, %{x: 1, y: 2, z: 3})`
>
> It might be worth exploring whether `Map.map` would be useful/efficient
> enough to add for piping purposes.
>
> -a
>
> On Tue, Jan 12, 2021 at 4:51 PM jonar.
ble to Elixir users like myself? I don’t care that the
>> > arguments are “backwards” from the pipeline, because `maps:map/2` is
>> > _incredibly_ useful and will improve some code that I have in
>> > production.
>> >
>> > -a
>> >
>>
While working with the v1.12.0 rc0 release, I wrote the following typespec:
@spec my_fun(1..10//2) :: boolean()
which resulted in the following error:
== Compilation error in file lib/foobar.ex ==
** (CompileError) lib/foobar.ex:6: type ..///3 undefined (no such type in
Foobar)
My confusion st
In our CI environment, we run our tests with this command:
mix test --warnings-as-errors
This is intended to fail when someone has created a warning within a test
file in addition to when the tests themselves fail. We have an earlier
check (MIX_ENV=test mix compile --force --warnings-as-errors