“&"没有参数 [英] The "&" with no parameters
本文介绍了“&"没有参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个:
case test123(&(:some_module.test456(789))) do
# ...
end
一个错误:
invalid args for &, expected an expression in the format of &Mod.fun/arity,
&local/arity or a capture containing at least one argument as &1,
got: :some_module.test456(789)
但是,我没有要传递给它的参数,以前它只是
However, I don't have a parameter to pass into it and previously it was merely
fn(_) -> :some_module.test456(789) end
如何解决?切换回"fn"?
How to fix it? Switch back to "fn"?
推荐答案
&
语法不能用于创建此类匿名函数,因为编译器无法知道您是否要创建0或1或2个或更多Arity函数.您必须继续使用 fn(_)->:some_module.test456(789)结尾
.
The &
syntax cannot be used to create such anonymous functions because the compiler can't know whether you wanted to create a 0 or 1 or 2 or more arity function. You'll have to keep using fn(_) -> :some_module.test456(789) end
.
这篇关于“&"没有参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文