代码:
%% Author: Administrator
%% Created: 2011-5-15
%% Description: TODO: Add description to test1
-module(test1, [Name]).
%%
%% Include files
%%
%%
%% Exported Functions
%%
-export([aaa/0, main/0]).
%%
%% API Functions
%%
main()->
io:format("aaaaa~n"),
THIS:aaa().
aaa()->
io:format("bbbbb~n").
%%
%% Local Functions
%%
------------------------------------------------------
THIS变量是用在用new函数创建对象的时候,才能使用。
运行结果:
1> M = test1:new("zhang").
{test1,"zhang"}
2> M:main().
aaaaa
bbbbb
ok