Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elixir Macros: convert atoms into vars

Tags:

macros

elixir

I want to create an Elixir macro that converts a list of atoms [:a, :b] to vars a, b. The value of a and b can be anything -- all that I want to achieve is creating a variable with the readable name of the atom passed in. Is this possible? If so, how?

like image 431
arami Avatar asked Jun 18 '14 18:06

arami


1 Answers

This can be done using Macro.var/1

like image 151
sasajuric Avatar answered Oct 23 '22 07:10

sasajuric