现在的位置: 首页 > 综合 > 正文

Erlang基础 – 模块声明、函数导出声明和注释

2019年06月20日 ⁄ 综合 ⁄ 共 311字 ⁄ 字号 评论关闭

 先创建一个helloworld.erl文件,文件内容如下:

%% This is a simple Erlang module

% 模块声明
-module(helloworld).

% 函数导出声明
-export([pie/0]).

% Test pie
pie() ->
	3.14.
 

通过shell编译、执行:

$ erl
Erlang R16B03 (erts-5.10.4) [source] [smp:2:2] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V5.10.4  (abort with ^G)
1> c(helloworld).
{ok,helloworld}
2> helloworld:pie().
3.14
3> 

抱歉!评论已关闭.