Elixir: how to make a structure enumerable

I have a structure:

my_struct = %MyStruct{a: 1, b: 2}

how to make it enumerable so i can use methods Enumon it?

+4
source share
1 answer

You can use Map.to_list(struct)instead Enum.to_list, since structures are just cards with a key __struct__.

+2
source

Source: https://habr.com/ru/post/1540739/


All Articles