“& 1"代表什么?lix剂功能是什么意思? [英] What does "&1" mean in elixir function?
本文介绍了“& 1"代表什么?lix剂功能是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用此功能,& 1
指的是什么?
Given this function, what does &1
refer to?
Enum.map [1, 2, 3, 4], &(&1 * 2)
推荐答案
& 1
引用回调函数将接收的第一个参数.和号本身(&
)是捕获功能的简写.这就是您可以扩展该功能的方式.
&1
refers to the first argument the callback function would receive. The ampersand by itself (&
) is a shorthand for a captured function. This is how you could expand that function.
Enum.map([1, 2, 3, 4], fn x -> x * 2 end)
fn->
等于&(......
x->x
等于 ...(& 1
可以在此处
这篇关于“& 1"代表什么?lix剂功能是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文