简体   繁体   English

Erlang无法在intellij中运行

[英]Erlang cannot run in intellij

Trying to run simple erlang file in intellij. 尝试在intellij中运行简单的erlang文件。

-module('Tutorial').

%% API
-export([helloWorld/0]).

helloWorld() -> io:write("Hello World").

But when I try to run I always get 但是当我尝试跑步时,我总会得到

init terminating in do_boot ()

{"init terminating in do_boot",{{unbound_var,'Tutorial'},[{erl_eval,exprs,2,[]}]}}
Crash dump is being written to: erl_crash.dump...done

Im using erlang 8.3 and a intellij plugin for erlang. 我正在使用erlang 8.3和erlang的intellij插件。

Use: 采用:

-module('tutorial').

in a file called: "tutorial.erl". 在名为“ tutorial.erl”的文件中。 The expression: "Tutorial" is interpreted as a variable (because the first letter is capitalized). 表达式:“ Tutorial”被解释为变量(因为首字母大写)。 When the runtime encounters this variable, it tries to evaulate it, but since it is not defined, you get the error. 当运行时遇到此变量时,它将尝试清除它,但是由于未定义它,因此会出现错误。

Sort of- atoms (which module names are) can be capitalized if surrounded by single quotes, as seen here. 如果用单引号引起来,则原子的排序(即模块名称)可以大写,如此处所示。 I'm not sure how you're running the code, but the following illustrates (the code is in Foo.erl). 我不确定您如何运行代码,但是以下示例说明了(代码在Foo.erl中)。

-module('Foo').

-export([bar/0]).

bar() ->
  io:format("foobar~n").

And then 接着

1> c("Foo.erl").
{ok,'Foo'}
2> 'Foo':bar().
foobar
ok
3> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM