Skip to content

Latest commit

 

History

History
36 lines (22 loc) · 824 Bytes

2016-07-28-elixir比较优秀的地方.md

File metadata and controls

36 lines (22 loc) · 824 Bytes

pipe 管道

它让你把一层层的逆着你的思维的函数调用变成了更直观的表现,比如说我们常常这么写代码:

IO.puts(tabularize(to_map(Store.get_host(host))))

# 或者

list_data = Store.get_host(host)
map = to_map(list)
formatted_output = tabularize(map)
IO.puts(formatted_output)

这样的代码在Elixir中可以被写成:

host
|> Store.get_host
|> to_map
|> tabularize
|> IO.puts

非常符合人的思考过程,1步步的执行。

原文链接