简体   繁体   English

药剂宏指令:将原子转换为变量

[英]Elixir Macros: convert atoms into vars

I want to create an Elixir macro that converts a list of atoms [:a, :b] to vars a, b. 我想创建一个Elixir宏,将宏[:a,:b]的列表转换为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? a和b的值可以是任何值,我想要实现的就是创建一个传入的原子具有可读名称的变量。这可能吗? If so, how? 如果是这样,怎么办?

这可以使用Macro.var/1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM