Created
September 1, 2008 16:28
-
-
Save arunthampi/8319 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Example of Erlang guards | |
-module(double). | |
-export([double/1]). | |
%% If guard expressions are separated by a comma, it means AND. | |
%% If guard expressions are separated by a semi-colon, it means OR. | |
double(X) when X > 0; X < 0 -> X * 2; | |
% If a function has multiple lines, each line (except the last), must be | |
% terminated by a comma | |
double(X) when X =:= 0 -> io:format("Trying to double a zero homie?~n"), | |
0. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment