“ |”是什么意思?在e剂中意味着什么? [英] What does "|>" mean in elixir?
问题描述
我正在阅读github上的一些代码长生不老药代码,并且看到 |>
经常被使用。它没有出现在文档站点上的操作的列表中。这是什么意思?
即
expires_at:std [ expires_in] |> ; expires_at,
这是管道运算符。从链接的文档中:
此运算符在左侧引入表达式,作为右侧函数调用的第一个参数。 / p>
示例
iex>
[1,[2],3] |> List.flatten()
[1、2、3]
上面的示例与调用
List.flatten([1,[2],3])
相同。
I'm reading through some code elixir code on github and I see |>
being used often. It does not appear in the list of operation on the documentation site. What does it mean?
i.e.
expires_at: std["expires_in"] |> expires_at,
This is the pipe operator. From the linked docs:
This operator introduces the expression on the left-hand side as the first argument to the function call on the right-hand side.
Examples
iex>
[1, [2], 3] |> List.flatten()
[1, 2, 3]
The example above is the same as calling
List.flatten([1, [2], 3])
.
这篇关于“ |”是什么意思?在e剂中意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!