I am trying to get my head around comprehensions and enum.each
I am trying to get phoenix to render a list of buttons.
My data structure is :
btn = [
{"first", "red", "myfunc1()"}
{"second", "blue", "myfunc2()"}
]
my first go at it was using comprehensions
for n <- btn,do: content_tag(:button, "#{elem(n, 0)}", class: "#{elem(n, 1)}", onclick: "#{elem(n, 2)}")
Which ended up as a eternal loop of doom
I assume this has something to do with me not directly doing something to n which in my mind should be the tuple.
so I tried Enum.each because it looks like the right tool for the job.
return = []
Enum.each a, fn x -> return++[elem(x,0)] end
I get :Ok from this but not the list I expected [“first”,“second”]
so I am thinking I am missing something really obvious