I know its possible to create a struct via %User{ email: '[email protected]' }
. But if I had a variable params = %{email: '[email protected]'}
is there a way to create that struct using that variable for eg, %User{ params }
.
This gives an error, just wondering if you can explode it or some other way?
You should use the
struct/2
function. From the docs: