lista – How can I convert a range to list in elixir?

Question:

If I define a range like the following,

rango = 1..5

Is there a way to convert it to list?

Answer:

I think this is what you are looking for

to_list (collection)

Convert the collection to a list

iex> Enum.to_list 1..5
[1, 2, 3, 4, 5]

I hope it helps you

Scroll to Top