我刚开始学习Erlang,所以我将其编码为new.erl
:
-module(new).
-export([hello_world]/0).
hello_world()->io:fwrite("Hello\n").
因此函数名为hello_world
,它将Hello
保存为字符串。
但每当我想运行这个程序时,我就会得到这样的结果:
new.erl:2: bad function arity
new.erl:3: Warning: function hello_world/0 is unused
error
那么这个问题怎么解决呢,这里面出了什么问题呢?
1条答案
按热度按时间c3frrgcw1#
You wrote:
It should be:
export
requires a list, where each element in the list is the function name followed by a slash followed by the arity of the function. A list does not have an arity, which is what you wrote.Note that when you are just writing test code, it is easier to use:
which will export all functions defined in your module.