Today I Learned

A Hashrocket project

Ready to join Hashrocket? Find Openings here and apply today.

Stepping into Elixir Ranges

Elixir 1.12 introduced a new syntax suggar into Ranges first..last//step.

iex(1)> 1..10 |> Enum.to_list()
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

iex(2)> 1..10//2 |> Enum.to_list()
[1, 3, 5, 7, 9]

iex(3)> 1..10//3 |> Enum.to_list()
[1, 4, 7, 10]

The same could already be done with the amazing Stream module by using the take_every/2.

Looking for help? At Hashrocket, we 💜 Elixir! From our many Elixir client projects, to sponsoring the Chicago Elixir Meetup, to the source code for this application, we are invested in this community. Contact us today to talk about your Elixir project.