gpt4 book ai didi

elixir - Elixir 中的斜线符号是什么意思?

转载 作者:行者123 更新时间:2023-12-03 23:28:02 30 4
gpt4 key购买 nike

在 Elixir 文档中,他们一直使用带有斜线的奇怪符号,例如:

is_boolean/1
IO.puts/1
String.length/1
is_function/2
++/2

我只是猜测,但我认为它指的是arity。但如果是这样的话,为什么文档中的任何地方都没有提到魔鬼呢?这似乎不是 IT 中的任何一种标准惯例(至少,在我从事 IT 工作的 20 多年中,我从未见过这样的惯例)。

最佳答案

来自 page 2, Basic types入门文档:

Note: Functions in Elixir are identified by name and by number of arguments (i.e. arity). Therefore, is_boolean/1 identifies a function named is_boolean that takes 1 argument. is_boolean/2 identifies a different (nonexistent) function with the same name but different arity.



Erlang/Elixir Syntax: A Crash Course 中也有描述。 :

Here we create a module named hello_module. In it we define three functions, the first two are made available for other modules to call via the export directive at the top. It contains a list of functions, each of which is written in the format <function name>/<arity>. Arity stands for the number of arguments.



我可能会推测这往往被归为 Elixir 文献中的旁注,因为它直接来自 Erlang。尽管使用 Elixir 不需要 Erlang 知识,但当人们记录从 Erlang 派生的 Elixir 软件时,这种遗漏是一个常见的错误。

关于elixir - Elixir 中的斜线符号是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36778114/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com