---
title: "Erlang使用if的示例"
author: "michael8335"
date: "2013-04-07T16:17:07Z"
tags: []
categories: ["编程语言"]
slug: "erlang-if"
draft: false
lastmod: "2013-04-07T16:17:07Z"
id: 1843141
url: "https://michael8335.iteye.com/blog/1843141"
---

```java

%%%-------------------------------------------------------------------
%%% @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.

```