Enum.chunk is deprecated in Elixir 1.8

#3 · closed · 2 comments

View on GitHub ↗

glauciom

Hi Stephen, https://github.com/StephenGrider/ElixirCode/blob/b291b8cbe400487392cb67aeabe84550c13dbbce/identicon/lib/identicon.ex#L11 `Enum.chunk` is deprecated in elixir 1.8 version and elixir's compiler suggests to use `Enum.chunk_every` instead. However, if you use this new function (only changing from `Enum.chunk` to `Enum.chunk_every`) the code fails. What would be the changes to make it works for elixir 1.8? Best Regards and keep the nice work as instructor.

Comments

glauciom

Ok, just saw your post saying to do not post issues here, sorry :)

jarvisjohnson

For anyone else finding this, the newer `chunk_every` function does not automatically discard the unmatched elements in the last chunk. It takes a :discard argument, which would tell the function to drop the unmatched elements. So this code in recent Elixir (1.9.2 right now) would be: ```elixir |> Enum.chunk_every(3, 3, :discard) ``` [Link to relevant docs](https://hexdocs.pm/elixir/Enum.html#chunk_every/2)