Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Given a module name atom, how can I create the struct for that module?

Tags:

elixir

I want to go from MyMod to %MyMod{} in order to keep backwards compatibility with an older configuration format in a library I'm making.

The module is already defined and calls the defstruct macro.

like image 240
lpil Avatar asked Jan 30 '16 21:01

lpil


1 Answers

The Kernel function struct/2 should work fine:

struct(MyMod)   # => %MyMod{}
like image 136
Christian Di Lorenzo Avatar answered Sep 29 '22 00:09

Christian Di Lorenzo