我想知道 Elixir 中方法名的确切含义:
array = [1,2,3]
module_name = :lists
method_name = :nth # this not working
module_name.method_name(1, array) # error, undef function lists.method_name/2
module_name.nth(1, array) # returns 1, module_name is OK. It's an atom
但我几乎可以在Erlang中做同样的事情:
A = [1,2,3].
X = lists.
Y = nth.
X:Y(1,A). # returns 1
我该如何在 Elixir 中实现这一操作?
module.method
,对吗? - halfelf:lists.:nth
)。在这种情况下,我宁愿使用 apply。 - lastcanalEnum.fetch
?是否有变量变量或变量函数? - CMCDragonkai