ITeye博客

Erlang使用if的示例

michael8335 · 2013-04-07 16:17 · Erlang · 编程语言 · Markdown


%%%-------------------------------------------------------------------
%%% @author YangFei  <yangf_sky@163.com>
%%% @doc this is a test on how to use 'if' in erlang
%%% @end
%%%-------------------------------------------------------------------

-module(if_test).

%%API
-export([test_if/1]).

%%--------------------------------------------------------------------
%% @doc test if 
%%
%% @spec test_if(Num::integer()) -> Result
%% where
%%  Result ::integer()
%% @end
%%--------------------------------------------------------------------

test_if(Num) ->
	if
		Num>=5 ->
			10;
		(Num>=0) and (Num<5) ->
			0;
		Num<0 ->
			pass
		end.

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。